flutter - 如何使用主题通用更改AppBar的文本颜色,FAB的图标颜色?

我可以将 AppBar 的背景颜色设置为 Colors.amber。这会自动将文本颜色设置为黑色。我知道可能出现的可访问性问题,但无论如何我希望文本颜色为白色。

我仍然可以从 AppBar 设置文本颜色,但我想通用设置它。

这是我为我的应用使用的主题。

title: 'Flutter Demo',
theme: new ThemeData(
  primarySwatch: Colors.amber,
  textTheme: Theme.of(context).textTheme.apply(
    bodyColor: Colors.white,
    displayColor: Colors.white,
  ),
),

最佳答案

我认为最直接的方法是调整您正在使用的主题的标题颜色:

theme: new ThemeData(
  primarySwatch: Colors.grey,
  primaryTextTheme: TextTheme(
    headline6: TextStyle(
      color: Colors.white
    )
  )
)

https://stackoverflow.com/questions/50619848/

相关文章:

flutter - 如何将两个 ListView 放在一个列中?

flutter - 如何在 Flutter 中将图像和文件上传到服务器?

asynchronous - 异步对调用者滚雪球,不能使构造函数异步

dart - 如何更改 textField 下划线颜色?

dart - 如何在 flutter 中创建工具栏搜索 View

flutter - Flutter 中 SliverList 与 ListView 的区别

generics - 为什么有状态的小部件在flutter中定义为两个类?

flutter - 变量名前的下划线 "_"对 Flutter 意味着什么

json - 类型 'List' 不是类型 'List' 的子类型,其中

dart - Flutter - 更改 OutlineInputBorder 的边框颜色