IT

[Flutter 앱 개발하기] 버튼 비활성화 (disable) 하기

검색일기 2023. 2. 7. 08:54
728x90

일정 조건이 만족할 때 만 버튼이 동작하고, 그렇지 않을 경우에는 비활성화 하여 사용자가 클릭하지 못하게 해야 한다면

 

onPressed 이벤트에 null을 설정하면 된다.

 

CupertinoButton(
	color: Colors.lightBlue,
	borderRadius: circularBorderRadius,
	child: Text("진행하기"),
	onPressed: (조건1 == true && 조건2 == true )
		? () {
				....
				print("do something");
			}
		: null),

 

728x90