【发布时间】:2020-05-08 00:26:58
【问题描述】:
我尝试在this article 中实施解决方案,但它对我不起作用。当我单击按钮时,它应该被禁用。此外,当我单击按钮并热重新加载应用程序时,它会禁用按钮。
我也尝试使用函数,但在访问小部件变量时遇到了困难。
bool _isButtonDisabled = false;
MaterialButton(
color: Colors.blue,
textColor: Colors.white,
disabledColor: Colors.grey,
disabledTextColor: Colors.black,
child: Text('Login'),
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(4)),
onPressed: _isButtonDisabled ? null : () async {
_isButtonDisabled = true;
// Login Stuff
}
)
【问题讨论】: