flutter - 全局编辑 AppBar 操作列表中 TextButton 小部件的颜色?

标签 flutter colors themes flutter-appbar

在我的根文件中,我有:

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/

相关文章:

flutter - 由匿名关闭错误定义的固定错误 : How to Solve The return type 'StreamController<ConnectivityStatus>' isn't a 'Stream' ,

flutter - 如何将背景图像添加到 flutter

eclipse - Eclipse 中的 UI 颜色

jQuery 改变 <img> 的色调、饱和度、gamma?

android - 如何更改 Android 按钮波纹颜色,同时保留其他样式属性?

css - Drupal - Apache 的 Mod_Deflate 破坏了 CSS

flutter - ListView 构建器项目的动态高度

flutter - 如何在 flutter 中向以下代码添加“全选”和“取消全选”按钮?

java - 为两个不同的 JButton 设置不同的禁用颜色? (UIManager.getDefaults 更改两个按钮)

jquery - 为什么我的 Themeroller 主题不呈现任何 CSS?