【发布时间】:2021-07-02 00:28:49
【问题描述】:
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
【问题讨论】:
-
按下时可以使用
setState改变颜色 -
@AkshayNayka ,我的意思是当你按下按钮时,它的 Splash 颜色会慢慢地填充按钮。它不是按钮颜色。
标签: flutter dart flutter-layout