prismTheme function
- Color seed = const Color(0xFF39A9DB),
- Brightness brightness = Brightness.light,
- PrismDensity density = PrismDensity.comfortable,
- PrismShape shape = PrismShape.rounded,
- PrismMotion motion = PrismMotion.standard,
- PrismTokens? tokens,
- ThemeData? base,
Builds a fully configured ThemeData for a Prism app.
One call replaces the three-step dance of seeding a scheme, registering tokens and remembering to pass the same brightness twice:
MaterialApp(
theme: prismTheme(seed: brandPurple),
darkTheme: prismTheme(seed: brandPurple, brightness: Brightness.dark),
)
base is respected and extended rather than replaced, so typography and
component themes you already configured survive.
Implementation
ThemeData prismTheme({
Color seed = const Color(0xFF39A9DB),
Brightness brightness = Brightness.light,
PrismDensity density = PrismDensity.comfortable,
PrismShape shape = PrismShape.rounded,
PrismMotion motion = PrismMotion.standard,
PrismTokens? tokens,
ThemeData? base,
}) {
final theme = base != null
? base.copyWith(
colorScheme: base.colorScheme.brightness == brightness
? base.colorScheme
: ColorScheme.fromSeed(seedColor: seed, brightness: brightness),
)
: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: seed,
brightness: brightness,
),
);
final resolved =
tokens ??
PrismTokenPresets.preset(density: density, shape: shape, motion: motion);
return theme.copyWith(
extensions: [
...theme.extensions.values.where((e) => e is! PrismTokens),
resolved,
],
);
}