develop/Flutter

[Flutter] Switch on/off 버튼 사용하기 (iOS와 AOS) - setting 화면 만들기

방뎁 2023. 4. 18. 10:15
반응형

on / off 를 할때, switch만큼 유용한게 없는것 같다

아래와 같은 버튼들을 만들어 보자

Switch Button 만들기

우선 변수를 하나 만들고 

bool _isChecked = false;

 

사용하는 방법은 매우 간단한데, 

먼저 

 

반응형

AOS 스타일 (Material)

 Switch(
    value: _isChecked,
    onChanged: (value) {
      setState(() {
        _isChecked = value;
      });
    },
),

 

aos 스타일 버튼
aos 스타일 버튼

iOS 스타일 (Cupertino)

CupertinoSwitch( 
    value: _isChecked,
    activeColor: CupertinoColors.activeBlue,
    onChanged: (bool? value) { 
      setState(() {
        _isChecked = value ?? false;
      });
    },
),

 

iOS 스타일 버튼
iOS 스타일 버튼

 

 

아래의 링크를 참조했습니다. 

https://api.flutter.dev/flutter/cupertino/CupertinoSwitch-class.html

 

CupertinoSwitch class - cupertino library - Dart API

An iOS-style switch. Used to toggle the on/off state of a single setting. The switch itself does not maintain any state. Instead, when the state of the switch changes, the widget calls the onChanged callback. Most widgets that use a switch will listen for

api.flutter.dev

 

ios, aos dropdown button 만드는 방법

2023.04.17 - [develop/Flutter] - [Flutter] dropdown button 만들기 iOS 스타일과 안드로이드 스타일

 

[Flutter] dropdown button 만들기 iOS 스타일과 안드로이드 스타일

Cupertino와 Material 우선 Cupertino는 iOS 스타일이고, Material은 android 스타일이다. Material app 으로 감싸고 있든, cupertino 로 감싸고 있든 dropdown은 어떤 스타일이든 만들 수 있다. dropdown button 만들기 iOS스

devfart.tistory.com

 

반응형