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
| // Copyright 2025 Fredrick Allan Grott. All rights reserved. | |
| // Use of this source code is governed by a BSD-style | |
| // license that can be found in the LICENSE file. | |
| // | |
| // Modified from the Material_3_Expressive package | |
| // MIT License by Emily Moonstone 2025 | |
| // ignore_for_file: prefer_constructors_over_static_methods, dead_code |
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
| /// Inject (or replace) the M3ETheme extension on a ThemeData. | |
| ThemeData withM3ETheme(ThemeData base, {M3ETheme? override}) { | |
| // Use any existing M3ETheme, else the provided override, else defaults. | |
| final current = base.extension<M3ETheme>(); | |
| final next = override ?? current ?? M3ETheme.defaults(base.colorScheme); | |
| // Merge existing extensions (values) with our M3ETheme, replacing prior ones. | |
| final Iterable<ThemeExtension<dynamic>> existing = base.extensions.values; | |
| final List<ThemeExtension<dynamic>> merged = <ThemeExtension<dynamic>>[]; | |
| for (final e in existing) { |
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
| // 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, |
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){ | |
| final light = ColorScheme.fromSeed(dynamicSchemeVariant: DynamicSchemeVariant.tonalSpot, | |
| contrastLevel: 0.1, | |
| seedColor: Colors.purple, brightness: Brightness.light).toM3EThemeData(); | |
| final dark = ColorScheme.fromSeed(dynamicSchemeVariant: DynamicSchemeVariant.tonalSpot, | |
| contrastLevel: 0.1, | |
| seedColor: Colors.purple, brightness: Brightness.dark).toM3EThemeData(); | |
| return MaterialApp( | |
| title: "Me". | |
| theme: light.toM3ETheme(), |
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
| factory M3ETypography.defaultFor( | |
| Brightness brightness, { | |
| String? brandFontFamily, | |
| String? plainFontFamily, | |
| TextTheme? baseOverride, | |
| }) { | |
| // 1) Start from Material 3 baseline type. | |
| final m3 = Typography.material2021(); | |
| final TextTheme m3Base = | |
| baseOverride ?? (brightness == Brightness.dark ? m3.white : m3.black); |
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
| factory Typography.material2021({ | |
| TargetPlatform? platform = TargetPlatform.android, | |
| ColorScheme colorScheme = const ColorScheme.light(), | |
| TextTheme? black, | |
| TextTheme? white, | |
| TextTheme? englishLike, | |
| TextTheme? dense, | |
| TextTheme? tall, | |
| }) { | |
| assert(platform != null || (black != null && white != null)); |
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
| // Copyright 2025 Fredrick Allan Grott. All rights reserved. | |
| // Use of this source code is governed by a BSD-style | |
| // license that can be found in the LICENSE file. | |
| // | |
| // Modified from the Material_3_Expressive package | |
| // MIT License by Emily Moonstone 2025 | |
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){ | |
| final light = ColorScheme.fromSeed(dynamicSchemeVariant: DynamicSchemeVariant.tonalSpot, | |
| contrastLevel: 0.1, | |
| seedColor: Colors.purple, brightness: Brightness.light).toM3EThemeData(); | |
| final dark = ColorScheme.fromSeed(dynamicSchemeVariant: DynamicSchemeVariant.tonalSpot, | |
| contrastLevel: 0.1, | |
| seedColor: Colors.purple, brightness: Brightness.dark).toM3EThemeData(); | |
| return MaterialApp( | |
| title: "Me". | |
| theme: light, |
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
| emphasizedOverride(birghtness) { | |
| ColorScheme tempColorScheme = ColorScheme.fromSeed(seedColor: Colors.blue, brightness: brightness, dynamicSchemeVariant: DynamicSchemeVariant.tonalSpot, contrastLevel: 0.0,); | |
| final Color dark = tempColorScheme.brightness == Brightness.light ? tempColorScheme.onSurface : tempColorScheme.surface; | |
| final Color light = tempColorScheme.brightness == Brightness.light ? tempColorScheme.surface : tempColorScheme.onSurface; | |
| return M3Emphasized( | |
| displayLarge: GoogleFonts.name(textStyle: TextStyle(color: brightness == Brightness.light ? dark : light, | |
| decorationColor: brightness == Brightness.light ? dark: light,), | |
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
| // Copyright 2025 Fredrick Allan Grott. All rights reserved. | |
| // Use of this source code is governed by a BSD-style | |
| // license that can be found in the LICENSE file. | |
| // | |
| // Modified from the Material_3_Expressive package | |
| // MIT License by Emily Moonstone 2025 | |
NewerOlder