Last active
May 17, 2023 19:59
-
-
Save nonsocchi/94d13992e632131e2d53bad3a9a41646 to your computer and use it in GitHub Desktop.
riverpod_app_theme: switching theme with provider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return Consumer( | |
builder: (_, ref, __) => MaterialApp( | |
debugShowCheckedModeBanner: false, | |
// Define a light and dark color theme. Then, read the user's | |
// preferred ThemeMode (light, dark, or system default) from the | |
// ThemingController to display the correct theme. | |
theme: ThemeData(useMaterial3: true), | |
darkTheme: ThemeData.dark(useMaterial3: true), | |
themeMode: ref.watch(themingControllerProvider), | |
home: const ThemingView(), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment