getPrimaryPalette method

  1. @override
TonalPalette getPrimaryPalette(
  1. TonalPaletteSourceColor sourceColor,
  2. Variant variant,
  3. bool isDark,
  4. double contrastLevel,
  5. Platform platform,
  6. SpecVersion specVersion,
)
override

Implementation

@override
TonalPalette getPrimaryPalette(
  TonalPaletteSourceColor sourceColor,
  Variant variant,
  bool isDark,
  double contrastLevel,
  Platform platform,
  SpecVersion specVersion,
) => switch (variant) {
  .content || .fidelity => .fromHueAndChroma(
    sourceColor.asHct.hue,
    sourceColor.asHct.chroma,
  ),
  .fruitSalad => .fromHueAndChroma(
    MathUtils.sanitizeDegreesDouble(sourceColor.asHct.hue - 50.0),
    48.0,
  ),
  .monochrome => .fromHueAndChroma(sourceColor.asHct.hue, 0.0),
  .neutral => .fromHueAndChroma(sourceColor.asHct.hue, 12.0),
  .rainbow => .fromHueAndChroma(sourceColor.asHct.hue, 48.0),
  .tonalSpot => .fromHueAndChroma(sourceColor.asHct.hue, 36.0),
  .expressive => .fromHueAndChroma(
    MathUtils.sanitizeDegreesDouble(sourceColor.asHct.hue + 240.0),
    40.0,
  ),
  .vibrant => .fromHueAndChroma(sourceColor.asHct.hue, 200.0),
  _ => throw ArgumentError.value(
    variant,
    "variant",
    "Variant is not supported in current spec.",
  ),
};