Remove unused dynamic field lookup and redundant utility methods; clean up pubspec dependency paths and update READMEs with detailed package guides.

This commit is contained in:
Emily Pauli 2025-10-23 18:12:39 +02:00
commit 401dd103a6
30 changed files with 799 additions and 64 deletions

View file

@ -20,3 +20,60 @@ flutter run -d chrome
```
_Last updated: 2025-10-23_
---
## Detailed Guide
### What this package provides
The design language core for Material 3 Expressive:
- M3ETheme ThemeExtension providing tokens for color, typography, shapes, spacing, elevation, and motion.
- Utilities to derive expressive surfaces (e.g., surfaceContainer levels) and harmonize with dynamic colors.
### Installation
```yaml
dependencies:
m3e_design: ^0.1.0
dynamic_color: ^1.8.1
```
Minimum SDK: Dart >=3.5.0.
### Quick start: add M3ETheme to ThemeData
```dart
final base = ThemeData(colorScheme: ColorScheme.fromSeed(seedColor: Colors.teal));
final m3e = M3ETheme.defaults(base.colorScheme);
return MaterialApp(
theme: base.copyWith(extensions: [m3e]),
home: const MyHomePage(),
);
```
With dynamic color (Android 12+):
```dart
DynamicColorBuilder(
builder: (lightDynamic, darkDynamic) {
final scheme = lightDynamic ?? ColorScheme.fromSeed(seedColor: Colors.teal);
final base = ThemeData(colorScheme: scheme);
final m3e = M3ETheme.defaults(base.colorScheme);
return MaterialApp(theme: base.copyWith(extensions: [m3e]), home: const MyHomePage());
},
)
```
### Token overview
- Colors: surface, onSurface, container tiers, primary/secondary/tertiary, outline, inverse, etc.
- Typography: headline/title/label/body scales incl. emphasized variants.
- Shapes: round/square families, radii by size category.
- Spacing: xs→xl ramps for consistent paddings.
- Motion: durations/easings for expressive transitions.
### Used by
All sibling packages in this monorepo use M3E tokens for consistent UI.
### Links
- Repository: https://github.com/EmilyMoonstone/material_3_expressive/tree/main/packages/m3e_design
- Issue tracker: https://github.com/EmilyMonestone/material_3_expressive/issues
- Changelog: ./CHANGELOG.md

View file

@ -174,33 +174,6 @@ class M3EColors {
Color _surfaceDim() => _blend(s.surface, s.onSurface, 0.05);
Color _surfaceBright() => _blend(s.surface, s.primary, 0.04);
Function(Invocation invocation)? _tryGet<T>(
ColorScheme scheme, String getter) {
try {
final dyn = scheme as dynamic;
final v =
dyn.__noSuchMethod__ == null ? null : null; // keep analyzer happy
return (dyn as dynamic)
.noSuchMethod; // never executed, trick to silence lints in try
} catch (_) {
// ignored
}
// Fallback path using mirrors is not available; we'll use a switch below.
return null;
}
// Read new fields via dynamic with try-catch (avoids hard SDK requirement)
Color _getOr(Color? c, Color Function() orElse) => c ?? orElse();
Color? _readColor(String name) {
try {
final dyn = s as dynamic;
return dyn.toJson != null ? null : (dyn as dynamic)[name] as Color?;
} catch (_) {
return null;
}
}
// While dynamic lookup above is intentionally conservative, we can directly
// access when fields exist in the current SDK, otherwise compute.
Color surfaceDim = (() {