美文网首页
flutter TextButton

flutter TextButton

作者: 那一只大象 | 来源:发表于2021-07-20 14:25 被阅读0次

    1.overlayColor: 按钮按下时水波纹颜色

    2.backgroundColor: 按钮背景色 

    3.foregroundColor: 按钮字体颜色

    4.设置不同状态 按钮字体颜色:

    foregroundColor: MaterialStateProperty.resolveWith((states)

    {

        if (states.contains(MaterialState.focused)) {

            return Colors.white;

        } else if (states.contains(MaterialState.pressed)) {

            //对应 faltbutton highlightcolor

            return Colors.red;

        }

    }),

    5. 设置button style 方式一:

    TextButton(

                                  onPressed: () => _dismissDialog(context),

                                  child: Text("取消",

                                      style: TextStyle(

                                          color: Colors.black12,

                                          fontSize: screenUtil.setSp(17))),

                                  style: ButtonStyle(

                                  overlayColor: MaterialStateProperty.all<Color>(Colors.transparent),//splashColor

                                    padding: MaterialStateProperty.all<EdgeInsetsGeometry>(EdgeInsets.all(0)),

                                    backgroundColor: MaterialStateProperty.all<Color>(Color(0xFFFFC800)),

                                    shape: MaterialStateProperty.all(RoundedRectangleBorder(

                                      borderRadius: BorderRadius.circular(24.0))),

                                    elevation: MaterialStateProperty.all<double>(0),

                                  )

                              )),

    6. 设置button style 方式二:

    TextButton(

              style: TextButton.styleFrom(

                backgroundColor: Color(0xFFFFC800),

                shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(24.0)),

                textStyle:

                  TextStyle(

                    color: Color(0xFF333333),

                  ),

              )

    相关文章

      网友评论

          本文标题:flutter TextButton

          本文链接:https://www.haomeiwen.com/subject/ofjjmltx.html