这是我的FlutButton:
FlatButton(
color: Colors.blue,
textColor: Colors.white,
disabledColor: Colors.grey,
disabledTextColor: Colors.black,
padding: EdgeInsets.all(8.0),
splashColor: Colors.blueAccent,
child: Text(
"Connectez-vous",
style: TextStyle(
fontSize: mobileWidth * 0.04,
),
),
onPressed: () {
if (RevendeurTemp != null) {
saveRevendeur(RevendeurTemp);
navigateToMainPage(context);
}
else {
print ("desabled") ;
null ;
}
},
),
当按钮被禁用并单击时,它会打印“disabled”,但按钮的样式与启用或禁用的样式相同。最佳答案
请检查下面的编辑代码。
FlatButton(
color: Colors.blue,
textColor: Colors.white,
disabledTextColor: Colors.black,
disabledColor: Colors.black12,
padding: EdgeInsets.all(8.0),
splashColor: Colors.blueAccent,
child: Text(
"Connectez-vous",
style: TextStyle(
fontSize: MediaQuery.of(context).size.width * 0.04,
),
),
onPressed: RevendeurTemp == ""
? null
: () {
saveRevendeur(RevendeurTemp);
navigateToMainPage(context);
},
)
关于flutter - Flutter FlutButton样式在禁用时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63972655/