【发布时间】:2019-05-11 17:51:43
【问题描述】:
Flutter 使用 Theme 并扩展/覆盖它的官方示例,如图所示不起作用。
我使用了颤振升级和颤振医生,所以我的颤振是最新的并且工作正常。
我猜安卓模拟器也可以正常工作。
我也重新启动了我的电脑,但它没有帮助。
我使用了这个网站的代码:https://flutter.dev/docs/cookbook/design/themes
floatingActionButton 应该是黄色的,但我的按钮是青色的。所以覆盖不起作用。 (如果需要我可以添加图片,但我认为我的问题很清楚。)
theme: ThemeData(
// Define the default Brightness and Colors
brightness: Brightness.dark,
primaryColor: Colors.lightBlue[800],
accentColor: Colors.cyan[600],
// Define the default Font Family
fontFamily: 'Montserrat',
// Define the default TextTheme. Use this to specify the default
// text styling for headlines, titles, bodies of text, and more.
textTheme: TextTheme(
headline: TextStyle(fontSize: 72.0, fontWeight: FontWeight.bold),
title: TextStyle(fontSize: 36.0, fontStyle: FontStyle.italic),
body1: TextStyle(fontSize: 14.0, fontFamily: 'Hind'),
),
),
floatingActionButton: Theme(
data: Theme.of(context).copyWith(accentColor: Colors.yellow),
child: FloatingActionButton(
onPressed: null,
child: Icon(Icons.add),
),
),
【问题讨论】:
-
你能添加浮动动作按钮的代码
-
这样吗?还是声明?
-
你的主题是否有参数
brightness: Brightness.Dark,因为我认为它会覆盖强调色 -
确实如此,但如果我删除它,它只会改变背景颜色。我把主要的主题代码放在问题中。