on / off 를 할때, switch만큼 유용한게 없는것 같다
아래와 같은 버튼들을 만들어 보자
Switch Button 만들기
우선 변수를 하나 만들고
bool _isChecked = false;
사용하는 방법은 매우 간단한데,
먼저
AOS 스타일 (Material)
Switch(
value: _isChecked,
onChanged: (value) {
setState(() {
_isChecked = value;
});
},
),
iOS 스타일 (Cupertino)
CupertinoSwitch(
value: _isChecked,
activeColor: CupertinoColors.activeBlue,
onChanged: (bool? value) {
setState(() {
_isChecked = value ?? false;
});
},
),
아래의 링크를 참조했습니다.
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
'develop > Flutter' 카테고리의 다른 글
[flutter] SKAdNetwork 앱 광고 추적 허용 요청하기 in iOS (0) | 2023.05.19 |
---|---|
[Flutter] 효과음 재생 시 백그라운드 뮤직 정지 되는 문제 야매로 해결하기 (다른 앱의 소리와 효과음이 동시에 재생되게 하기) (0) | 2023.05.17 |
[Flutter] dropdown button 만들기 iOS 스타일과 안드로이드 스타일 (0) | 2023.04.17 |
[flutter] json Dart Model 객체로 맵핑하기 라이브러리 X 웹으로 생성 (0) | 2023.04.14 |
[Flutter] 그림자 버튼 만들기 BoxShadow 사용하기 (0) | 2023.04.09 |