Colours.dark_app_main:Colours.app_main,// 页面背景色scaffoldBackgroundColor:isDarkMode?Colours.dark_bg_color:Colors.white,// 主要用于Material背景色canvasColor:isDarkMode?Colours.dark_material_bg:Colors.white,// 文字选择色(输入框复制粘贴菜单)textSelectionColor:Colours.app_main.withAlpha(70),textSel...
switch(theme) {case 'Dark':return ThemeMode.dark;case 'Light':return ThemeMode.light;default:return ThemeMode.system;}}ThemeDatagetTheme({bool isDarkMode =false}) {return ThemeData(errorColor: isDarkMode ? ColorR.dark_red : ColorR.red,brightness: isDarkMode ? Brightness.dark : Brightness.l...
dark: ThemeData.dark(useMaterial3: true), initial: savedThemeMode ?? AdaptiveThemeMode.light, debugShowFloatingThemeButton: true, builder: (theme, darkTheme) => MaterialApp( title: 'Flutter Demo', theme: theme, darkTheme: darkTheme, home: const MyHomePage(title: 'Flutter Demo Home Page'),...
Flutter makes it easy and fast to build beautiful apps for mobile and beyond - switch macOS dark mode KVO to effectiveAppearance/NSAppearance · flutter/flutter@d1e17c3
// If you do not have a themeMode switch, uncomment this line // to let the device system mode control the theme mode: themeMode: ThemeMode.system, home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } 运行 通过FlexSchemeColor 自定义颜色 ...
false; } static Future<void> updateThemeMode(bool isDarkMode) async { SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setBool(isDarkModeText, isDarkMode); }}// global_state.dartclass GlobalState extends ChangeNotifier { bool isDarkMode = true; GlobalState(this...
} } //获取主题 void getTheme() { switch (AppBox.shared.theme) { case 0: themeStr.value = Local.followerSystemTheme.tr; break; case 1: themeStr.value = Local.lightMode.tr; break; case 2: themeStr.value = Local.darkMode.tr; break; default: themeStr.value = Local.followerSystemTheme...
bool res = LocalCacheSync.userDefault['isDarkMode']; String res = LocalCacheSync.userDefault['token']; Map res = LocalCacheSync.userDefault['x-config']; 1. 2. 3. 管理一组数据缓存 如果你需要管理一系列值,请使用LocalCacheLoader,只需要一个channel标志,你就可以管理一系列值。
switch (getTextTheme(button)) { case ButtonTextTheme.normal: return getBrightness(button) == Brightness.dark ? Colors.white : Colors.black87; case ButtonTextTheme.accent: return colorScheme.secondary; case ButtonTextTheme.primary: { final Color fillColor = getFillColor(button); final bool fill...
In order to manage the state of the Cupertino switch, we need a new provider as follows: 12345finalisDarkModeProvider = Provider <bool> ((ref) {finalthemeMode = ref.watch(themeModeProvider) .state;returnthemeMode == ThemeMode.dark; }); ...