Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created January 23, 2026 13:39
Show Gist options
  • Select an option

  • Save fredgrott/ed048739a1f46e6a06a02f73a6dafbe0 to your computer and use it in GitHub Desktop.

Select an option

Save fredgrott/ed048739a1f46e6a06a02f73a6dafbe0 to your computer and use it in GitHub Desktop.
theme extension example
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