prismTheme function

ThemeData prismTheme({
  1. Color seed = const Color(0xFF39A9DB),
  2. Brightness brightness = Brightness.light,
  3. PrismDensity density = PrismDensity.comfortable,
  4. PrismShape shape = PrismShape.rounded,
  5. PrismMotion motion = PrismMotion.standard,
  6. PrismTokens? tokens,
  7. 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,
    ],
  );
}