how to implement dark mode in flutter

后端 未结 6 2272
终归单人心
终归单人心 2021-02-05 09:05

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 custo

6条回答
  •  忘掉有多难
    2021-02-05 09:27

    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 or provider for seamless experience.

提交回复
热议问题