flutter - Flutter FlutButton样式在禁用时不起作用

标签 flutter dart flutter-layout

这是我的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”,但按钮的样式与启用或禁用的样式相同。
My Button image

最佳答案

请检查下面的编辑代码。

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/

相关文章:

flutter - Flutter Web 应用程序中的文本可以搜索吗?

angular - Flutter:将数据传递给 WebView

dart - 列 mainAxisSize : MainAxisSize. 分钟不工作

flutter - 参数类型 'AnimationController?' 无法分配给参数类型 'Animation<double>'

flutter - 重新触发淡入淡出过渡

Flutter 依赖错误

flutter - 如何在GridView中增加卡片大小

Flutter:如何同步使用 SharedPreferences?

flutter - 如何在flutter中关注 ListView 中最新添加的项目

RangeSlider 上的 Flutter RangeLabels 不起作用