如何检查使用Flutter的Android Q中是否启用了暗模式?我知道如何设置黑暗模式,但是我没有找到检查背景主题的方法。
这是设置黑暗主题的代码。
darkTheme: ThemeData.dark(),
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的 flutter 应用程序中实现黑暗模式,但我不知道我错过了什么,但它在 iOS 上不起作用。我设法在 Android 上运行得很好,但当我打印时,WidgetsBinding.instance.window.platformBrightness仍然有光,当黑暗模式打开时。
当我设置 themeMode: ThemeMode.dark - 深色模式正常工作时,问题出在自动检测上。
另外,当我运行新的空白项目时,深色模式工作正常。但在我构建的应用程序中,它不起作用。即使themeMode设置为ThemeMode.system:
themeMode: ThemeMode.system,
theme: ThemeData(
accentColor: darkBlue,
cursorColor: red,
primaryColor: Colors.white,
brightness: Brightness.light,
),
darkTheme: ThemeData(
accentColor: Colors.white,
cursorColor: red,
primaryColor: Colors.white,
brightness: Brightness.dark,
),
Run Code Online (Sandbox Code Playgroud)
您有什么想法吗?可能出了什么问题,或者您有什么建议吗?
Flutter 版本:1.12.13-hotfix.9和 iOS 版本:iPhone SE 模拟器 - iOS 13.3
多谢。