Created
January 23, 2026 13:39
-
-
Save fredgrott/ed048739a1f46e6a06a02f73a6dafbe0 to your computer and use it in GitHub Desktop.
theme extension example
This file contains hidden or 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
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| theme: ThemeData( | |
| extensions: const <ThemeExtension<dynamic>>[ | |
| MyColors(brandColor: Color(0xFF1E88E5), danger: Color(0xFFE53935)), | |
| ], | |
| ), | |
| darkTheme: ThemeData.dark().copyWith( | |
| extensions: <ThemeExtension<dynamic>>[ | |
| const MyColors(brandColor: Color(0xFF90CAF9), danger: Color(0xFFEF9A9A)), | |
| ], | |
| ), | |
| themeMode: isLightTheme ? ThemeMode.light : ThemeMode.dark, | |
| home: Home(isLightTheme: isLightTheme, toggleTheme: toggleTheme), | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment