在我的根文件中,我有:
theme: ThemeData(
appBarTheme: AppBarTheme(
textTheme: TextTheme(
button: TextStyle(color: Colors.white),
),
),
),
在我的自定义 AppBar 文件中:
return AppBar(
automaticallyImplyLeading: false,
backgroundColor: Colors.transparent,
actions: <Widget>[
TextButton(
child: Text('Sign in'),
onPressed: () {},
),
],
);
但文本仍保持默认的浅蓝色。
最佳答案
您在 AppBar 中使用 TextButton
,但未在代码中定义其主题。您需要定义 TextButtonTheme为了更改 TextButton 文本的颜色。像这样。
ThemeData(
textbuttonTheme: TextbuttonThemeData(
style: Textbutton.styleFrom(primary: Colors.teal)),
),
关于flutter - 全局编辑 AppBar 操作列表中 TextButton 小部件的颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65835474/