【发布时间】:2020-05-20 07:31:15
【问题描述】:
我在复制ThemeData.light() 后尝试更改accentColor,然后我有这个带有FloatingActionButton 的示例屏幕
class Sample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
)}}
然后在main.dart 的主窗口小部件中调用runApp,如果我像这样为MaterialApp 窗口小部件设置ThemeData,FloatingActionButton 将具有橙色。
theme: ThemeData(
accentColor: Colors.orange
)
但如果我尝试从Themedata.light().copyWith 继承颜色,FloatingActionButton 仍将具有来自浅色主题的蓝色。
theme: ThemeData.light().copyWith(
accentColor: Colors.orange
)
我原以为FloatingActionButton 应该是橙色,因为它继承了light 主题并覆盖了accentColor。
【问题讨论】:
标签: flutter dart material-design flutter-layout