logo

[Flutter]토글버튼 만들기

language-logoFlutter

• `ToggleButtonWidget` 클래스는 상태 관리를 위해 `ValueNotifier`를 사용하며, `_controllerbutton`의 값 변경에 따라 `_check` 상태를 업데이트한다.
• `AdvancedSwitch` 위젯을 사용하여 스위치 UI를 구현하고, 스위치의 상태는 `_controllerbutton`에 의해 제어된다.
• GetX를 사용하여 컨트롤러를 구현할 경우, `SwitchController` 클래스를 만들어 `ValueNotifier`를 관리하고, `toggleSwitch` 메소드로 스위치의 상태를 토글한다.
• GetX를 사용하면 `initState`와 `dispose` 메소드를 사용하지 않아도 되어 코드를 간결하게 작성할 수 있다.

thumbnail
북마크
공유하기
신고하기
1분 분량
조회수 365
profile-image오정현
5달 전
Copyright © 2024. Codenary All Rights Reserved.