【发布时间】:2022-01-05 09:24:11
【问题描述】:
我刚刚开始使用 Flutter 的一个新项目,而且对它完全陌生。
在 Flutter 中定义主题的惯例是什么?
我想要一个带有主题的单独文件,以保持main.dart 简单。有没有好的/正确/经典的方法来做到这一点?
目前我的main.dart 看起来像这样:
void main() => runApp(MaterialApp(
initialRoute: '/',
theme: ThemeData(
appBarTheme: AppBarTheme(
color: Colors.teal,
),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(
primary: Colors.teal,
)),
scaffoldBackgroundColor: Colors.grey[200],
textTheme: TextTheme(
bodyText1: TextStyle(),
bodyText2: TextStyle(),
).apply(
bodyColor: Colors.teal[800],
)),
routes: {
'/': (context) => Loading(),
'/home': (context) => Home(),
'/alarms': (context) => SetUpAlarm(),
},
));
【问题讨论】:
标签: flutter dart styles themes