iOS Flutter暗模式不会立即更改

时间:2020-03-09 13:02:35

标签: flutter dart flutter-layout ios-darkmode

我不确定这是否是抖动问题,但是每当我从控制中心更改亮/暗模式时,主题都不会立即改变。仅在解散控制中心并恢复应用程序后,它才会开始更改。我已经上传了gif图像来解释这个问题。

如果我与Reddit等其他应用进行比较,则在控制中心切换暗模式后,背景会立即变为暗

Flutter toggle light dark mode

目前,我正在使用默认的材质应用主题

main.dart

@override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: AppTheme.lightTheme,
      darkTheme: AppTheme.darkTheme,
      home: HomeWidget()
    );
  }

AppTheme.dart

class AppTheme {

  AppTheme._();

  static final ThemeData lightTheme = ThemeData(
      canvasColor: Colors.transparent,
      scaffoldBackgroundColor: Colors.grey.shade100,
      textTheme: TextTheme(
          bodyText1: TextStyle(color: Colors.black),
          caption: TextStyle(color: Colors.grey.shade700),
          headline6: TextStyle(color: Colors.black)
      ),
      iconTheme: IconThemeData(
          color: Colors.black
      ),
      appBarTheme: AppBarTheme(brightness: Brightness.light),
      brightness: Brightness.light
  );

  static final ThemeData darkTheme = ThemeData(
      canvasColor: Colors.transparent,
      scaffoldBackgroundColor: Color(0xff111215),
      textTheme: TextTheme(
          bodyText1: TextStyle(color: Color(0xffd0d2d4)),
          caption: TextStyle(color: Color(0xff717579)),
          headline6: TextStyle(color: Color(0xffd0d2d4))
      ),
      iconTheme: IconThemeData(
          color: Color(0xff9aa0a6)
      ),
      appBarTheme: AppBarTheme(brightness: Brightness.light),
      brightness: Brightness.light
  );
}

1 个答案:

答案 0 :(得分:0)

您是否正在调试模式或发布模式下对其进行检查。如果要在调试模式下进行检查,则只需在发布模式下进行检查(调试模式会有点慢)。

让我知道它是否有效