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) {
  .neutral => .fromHueAndChroma(
    sourceColor.asHct.hue,
    platform == .phone
        ? (Hct.isBlue(sourceColor.asHct.hue) ? 12.0 : 8.0)
        : (Hct.isBlue(sourceColor.asHct.hue) ? 16.0 : 12.0),
  ),
  .tonalSpot => .fromHueAndChroma(
    sourceColor.asHct.hue,
    platform == .phone && isDark ? 26.0 : 32.0,
  ),
  .expressive => .fromHueAndChroma(
    sourceColor.asHct.hue,
    platform == .phone ? (isDark ? 36.0 : 48.0) : 40.0,
  ),
  .vibrant => .fromHueAndChroma(
    sourceColor.asHct.hue,
    platform == .phone ? 74.0 : 56.0,
  ),
  _ => super.getPrimaryPalette(
    sourceColor,
    variant,
    isDark,
    contrastLevel,
    platform,
    specVersion,
  ),
};