Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created January 23, 2026 15:52
Show Gist options
  • Select an option

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

Select an option

Save fredgrott/c16009a4f060ec7496586cf0e9cdf58f to your computer and use it in GitHub Desktop.
colorscheme extension
// Convenience creation helpers to install M3ETheme with minimal boilerplate.
extension M3EColorSchemeAccessors on ColorScheme {
/// Creates a ThemeData from this ColorScheme and installs the M3ETheme
/// extension in one call.
///
/// Example:
/// final theme = ColorScheme.fromSeed(seedColor: Colors.teal).toM3EThemeData();
ThemeData toM3EThemeData({bool useMaterial3 = true, M3ETheme? override, ThemeData? base}) {
final ThemeData seed = base ?? ThemeData(useMaterial3: useMaterial3, colorScheme: this);
return withM3ETheme(seed, override: override);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment