checkBox, checkBoxListTile && radio && 물결제거 && navigator 페이지 관리

Flutter

목록 보기
11/12

버튼 물결 스타일 제거

TextButton(
onPressed: () {
// 버튼 동작
},
style: ButtonStyle(
overlayColor: MaterialStateProperty.all(Colors.transparent), // 물결 효과 제거
),
child: Text('No Ripple Effect'),
)

체크박스 사용법

리스트타일 + 체크박스 사용법

ListTile(
                leading: Checkbox(
                  value: _all,
                  activeColor: Colors.blueAccent,
                  onChanged: (bool? value) {
                    setState(() {
                      _all=value ?? false;
                      _agree1= value ?? false;
                      _agree2= value ?? false;
                      _agree3= value ?? false;
                      _agree4= value ?? false;
                      _agree5= value ?? false;
                    });
                  },
                ),
                // splashColor: Colors.transparent,  // ripple effect 제거
                // selectedTileColor: Colors.transparent, // 선택된 타일 색상 제거
                title: Text(style: TextStyle(color:_all == false ? Colors.black : Colors.blueAccent,fontWeight: _all == false ? FontWeight.w300 : FontWeight.w700),'모두 동의합니다.'),
              ),

체크박스 리스트타일 사용법

CheckboxListTile(
                  activeColor: Colors.blueAccent,
                  controlAffinity: ListTileControlAffinity.leading, // 체크박스를 leading으로 설정
                  title: Text('[필수] 페달 블랙박스 화면 보여주기',style:TextStyle(color:_agree1 == false ? Colors.black : Colors.blueAccent)),
                  value: _agree1,
                  onChanged: (bool? value) {
                    setState(() {
                      _agree1= value ?? false;
                      _all = _agree1 && _agree2 && _agree3 && _agree4 && _agree5;
                    });
                  },
                ),

체크박스 - 체크박스 리스트타일 차이

  • 체크박스 리스트 타일은 전체가 버튼이 됨 Inkwell 사용하는듯.

pushReplacement

pushReplacement 메서드는 현재 페이지를 스택에서 제거하고 새로운 페이지로 교체합니다. 이전 페이지로 돌아갈 수 없습니다.

dart
코드 복사
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => NewPage()),
);

pushAndRemoveUntil

pushAndRemoveUntil 메서드는 스택의 모든 페이지를 제거하고 지정된 조건에 따라 새로운 페이지를 추가합니다. 예를 들어, 이전에 쌓였던 모든 페이지를 제거하고 새 페이지로 이동하려면 다음과 같이 사용합니다:

dart
코드 복사
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) => NewPage()),
(Route route) => false, // 모든 기존 경로 제거
);

0개의 댓글