본문 바로가기
23G/일기

[TIL] Flutter Togglebuttons | vertical toggle switch with active border, with radius style

by 23g 2022. 8. 19.

 

토글 버튼 : Togglebuttons 위젯 / onPressed

 

toggle_switch | Flutter Package

Toggle Switch - A simple toggle switch widget. It can be fully customized with desired icons, width, colors, text, corner radius etc. It also maintains selection state.

pub.dev

 

[Flutter] 10. 토글 버튼 만들기(ToggleButtons)

지난포스트에서 StatefulWidget에 대해 알아보고 StatefulWidget 클래스를 만들었습니다. 지금 부터 bmi_scrren.dart파일에 체질량 계산기 화면을 만들려고 합니다. 체질량 계산기의 화면 UI는 미터

nayotutorial.tistory.com



-> Toggle
→ Togglebuttons 위젯, DropdownButton , vertical toggle switch with active border

with radius style

//With radius style
ToggleSwitch(
  minWidth: 90.0,
  cornerRadius: 20.0,
  activeBgColors: [[Colors.green[800]!], [Colors.red[800]!]],
  activeFgColor: Colors.white,
  inactiveBgColor: Colors.grey,
  inactiveFgColor: Colors.white,
  initialLabelIndex: 1,
  totalSwitches: 2,
  labels: ['True', 'False'],
  radiusStyle: true,
  onToggle: (index) {
    print('switched to: $index');
  },
),

vertical toggle switch witg active border

//vertical toggle switch with active border
ToggleSwitch(
  activeBorders: [
    Border.all(
      color: Colors.purple,
      width: 3.0,
    ),
    Border.all(
      color: Colors.yellow.shade700,
      width: 3.0,
    ),
    Border.all(
      color: Colors.deepOrangeAccent,
      width: 3.0,
    ),
    Border.all(
      color: Colors.blue.shade500,
      width: 3.0,
    ),
  ],
  activeFgColor: Colors.black54,
  isVertical: true,
  minWidth: 150.0,
  radiusStyle: true,
  cornerRadius: 20.0,
  initialLabelIndex: 2,
  activeBgColors: [
    [Colors.purpleAccent],
    [Colors.yellow],
    [Colors.orange],
    [Colors.lightBlueAccent]
  ],
  labels: ['Spring', 'Summer', 'Fall', 'Winter'],
  onToggle: (index) {
    print('switched to: $index');
  },
),