forked from mirrors/material_3_expressive
Revert m3e_design version to 0.2.0; add theme accessors to simplify retrieval of M3E theme from ThemeData. Update changelog and refactor BuildContext extension with new accessor.
This commit is contained in:
parent
a255494ec1
commit
eef97c0938
4 changed files with 19 additions and 3 deletions
|
|
@ -97,3 +97,16 @@ class _M3ETypeProxy {
|
|||
TextStyle get headlineSmallEmphasized =>
|
||||
(_t.base.headlineSmall ?? _empty).merge(_t.emphasized.headline);
|
||||
}
|
||||
|
||||
// Accessors for getting the M3E theme from ThemeData via Theme.of(context).m3e
|
||||
extension M3EThemeAccessors on ThemeData {
|
||||
// Returns the installed M3ETheme; in release builds falls back to defaults
|
||||
M3ETheme get m3e {
|
||||
final e = extension<M3ETheme>();
|
||||
assert(
|
||||
e != null,
|
||||
'M3ETheme is not installed on ThemeData. Wrap your app theme with withM3ETheme(...)',
|
||||
);
|
||||
return e ?? M3ETheme.defaults(colorScheme);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/m3e_theme.dart';
|
||||
|
||||
extension BuildContextM3EX on BuildContext {
|
||||
M3ETheme get m3e =>
|
||||
Theme.of(this).extension<M3ETheme>() ?? M3ETheme.defaults(Theme.of(this).colorScheme);
|
||||
M3ETheme get m3e => Theme.of(this).m3e;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue