颤振:关闭黑暗模式主题

时间:2020-05-02 21:02:47

标签: flutter

当我在手机上启用了暗模式的情况下测试我的应用程序时,cupertinoTabBar的更改会变成暗主题。我该如何预防?我只希望我的应用以浅色模式为主题。

2 个答案:

答案 0 :(得分:0)

在您的顶级应用组件(例如 MaterialApp)上将 ThemeMode.light 设置为 themeMode 字段。

例如。

MaterialApp(
   themeMode: ThemeMode.light,
)

此外,Flutter 中还有 3 种模式。

//Use either the light or dark theme based on what
//the user has selected in the system settings.
ThemeMode.system

// Always use the light mode regardless of system preference.
ThemeMode.light

//Always use the dark mode (if available) regardless of system preference.
ThemeMode.dark

答案 1 :(得分:0)

这里还有一个很好的主题:https://github.com/flutter/flutter/issues/41067#issuecomment-571689955

我无法更改顶部栏的颜色。解决办法是添加

<key>UIUserInterfaceStyle</key>
<string>Light</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<true/>

并将其添加到您的 dart 代码中:

import 'package:flutter/services.dart';
/// ...
SystemChrome.setSystemUIOverlayStyle(
      SystemUiOverlayStyle(statusBarBrightness: Brightness.light) // Or Brightness.dark
);

这将强制您的状态栏变为黑色而不是白色。

相关问题