本文介绍了如何在抖动中实现黑暗模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个具有2个明暗模式主题的flutter应用程序,该主题可以通过应用程序内的开关更改,默认主题为默认android主题。
我需要将一些自定义颜色传递给伙伴小部件,我不想只配置材料主题。
I want to create a flutter app that has 2 light and dark mode themes that change by a switch in-app and the default theme is default android theme.
I need to pass some custom color to the fellow widget and I don't want to just config material theme.
- 如何检测用户设备默认主题?
- 第二个问题是如何为整个应用提供主题?
- 第三是如何在运行时间中通过简单的切换来更改主题?
推荐答案
MaterialApp(
title: 'App Title',
theme: ThemeData(
brightness: Brightness.light,
/* light theme settings */
),
darkTheme: ThemeData(
brightness: Brightness.dark,
/* dark theme settings */
),
themeMode: ThemeMode.dark,
/* ThemeMode.system to follow system theme,
ThemeMode.light for light theme,
ThemeMode.dark for dark theme
*/
debugShowCheckedModeBanner: false,
home: YourAppHomepage(),
);
您可以使用获得无缝体验。
You can use scoped_model for seamless experience.
这篇关于如何在抖动中实现黑暗模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!