flutter TextButton

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),

              ),

          )

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容