Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created January 26, 2026 16:24
Show Gist options
  • Select an option

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

Select an option

Save fredgrott/0dfcddbb6cff097c4640d9770d8bf730 to your computer and use it in GitHub Desktop.
using M3ETheme, the dynamic color way
@override
Widget build(BuildContext context) {
return DynamicColorBuilder(
builder: (lightDynamic, darkDynamic){
final light = lightDynamic ?? ColorScheme.fromSeed(seedColor: Colors.teal);
final dark = darkDynamic ??
ColorScheme.fromSeed(seedColor: Colors.teal, brightness: Brightness.dark);
return MaterialApp(
theme: light.toM3EThemeData(override: M3eOverride(colors: M3ECustomColors.from(light),
typography: M3ECustomTypography(base: CustomTextTheme, emphasized: MyM3ECustomEmphasized ),
shapes: M3ECustomShapes.expressive(),
spacing: M3ECustomSpacing.regular(),
motion: M3EMotion.expressive()),
base: ThemeDataWithCustomComponentThemes(colorScheme: light) ),
darkTheme: dark.toM3EThemeData(override: M3eOverride(colors: M3ECustomColors(dark),
typography: M3ECustomTypography(base: CustomTextTheme, emphasized: MyM3ECustomEmphasized ),
shapes: M3ECustomShapes.expressive(),
spacing: M3ECustomSpacing.regular(),
motion: M3EMotion.expressive()),
base: ThemeDataWithCustomComponentThemes(colorScheme: dark)),
home: const MyHomePage(),
);
},
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment