# Theme

由于 Flutter 本身的主题配置已经足够丰富,这里只是增加一些快捷方法和局部扩充。

# Dark Mode

dark mode

组件会从上下文读取当前 Theme 的 brightness 属性,你可以类似下面的方式配置 theme:

ThemeData _buildDarkTheme() {
  final ThemeData base = ThemeData(
    brightness: Brightness.dark,
    // colors ...
    cupertinoOverrideTheme: CupertinoThemeData(
      brightness: Brightness.dark,
    ),
  );
  return base;
}

ThemeData _buildLightTheme() {
  final ThemeData base = ThemeData(
      brightness: Brightness.light,
      // colors ...
      cupertinoOverrideTheme: CupertinoThemeData(
        brightness: Brightness.light,
      ));
  return base;
}

然后在 MaterialApp 里对 mode, theme 以及 darkTheme 进行赋值:

MaterialApp(
    title: 'FLUI',
    themeMode: themeMode,
    theme: _buildLightTheme(),
    darkTheme: _buildDarkTheme(),
    routes: [...]
)

# FLPrimaryColorOverride

FLPrimaryColorOverride 可以为子组件配置新的主颜色。

FLPrimaryColorOverride(
    color: Colors.blue,
    child: RaisedButton(
        child: Text('Color Override');
    ),
    onPressed: (){}
)