gpt4 book ai didi

Flutter 2.0 - 如何在按下时更改文本按钮的初始颜色

转载 作者:行者123 更新时间:2023-12-04 03:30:33 25 4
gpt4 key购买 nike

FlatButton is deprecated and shouldn't be used. Used TextButton instead.在我之前的 FlatButton 小部件上,我可以在按下时更改初始颜色。但是现在我正在使用 TextButton 小部件,如何在 MaterialApp ThemeData 或直接在 TextButton 小部件上以有效的方式更改其颜色。
目前这是我的 TextButton

TextButton(
style: TextButton.styleFrom(
primary: Colors.red,
textStyle: TextStyle(
color: Colors.black45,
fontFamily: "Courier Prime",
),
backgroundColor: Colors.transparent,
),
onPressed: () {},
child: Text(
"Student",
style: TextStyle(fontWeight: FontWeight.bold),
),
),
overlayColor is used to indicate that the button is focused, hovered, or pressed. 但我找不到这个 overlayColor

最佳答案

TextButton(            
style: ButtonStyle(
overlayColor: MaterialStateColor.resolveWith((states) => Colors.red),
),
child: ...,
)
引用 Flutter TextButton splashColor property

关于Flutter 2.0 - 如何在按下时更改文本按钮的初始颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66964965/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com