primary property

  1. @override
DynamicColor get primary
override

Implementation

@override
DynamicColor get primary {
  final color2025 = DynamicColor(
    name: "primary",
    palette: (scheme) => scheme.primaryPalette,
    tone: (scheme) {
      if (scheme.variant == .neutral) {
        if (scheme.platform == .phone) {
          return scheme.isDark ? 80.0 : 40.0;
        } else {
          return 90.0;
        }
      } else if (scheme.variant == .tonalSpot) {
        if (scheme.platform == .phone) {
          if (scheme.isDark) {
            return 80.0;
          } else {
            return _tMaxC(scheme.primaryPalette);
          }
        } else {
          return _tMaxC(scheme.primaryPalette, 0, 90);
        }
      } else if (scheme.variant == .expressive) {
        if (scheme.platform == .phone) {
          return _tMaxC(
            scheme.primaryPalette,
            0,
            Hct.isYellow(scheme.primaryPalette.hue)
                ? 25
                : Hct.isCyan(scheme.primaryPalette.hue)
                ? 88
                : 98,
          );
        } else {
          // WATCH
          return _tMaxC(scheme.primaryPalette);
        }
      } else {
        // VIBRANT
        if (scheme.platform == .phone) {
          return _tMaxC(
            scheme.primaryPalette,
            0,
            Hct.isCyan(scheme.primaryPalette.hue) ? 88 : 98,
          );
        } else {
          // WATCH
          return _tMaxC(scheme.primaryPalette);
        }
      }
    },
    isBackground: true,
    background: (scheme) {
      if (scheme.platform == .phone) {
        return scheme.isDark ? surfaceBright : surfaceDim;
      } else {
        return surfaceContainerHigh;
      }
    },
    contrastCurve: (scheme) => scheme.platform == .phone
        ? _getContrastCurve(4.5)
        : _getContrastCurve(7),
    toneDeltaPair: (scheme) => scheme.platform == .phone
        ? ToneDeltaPair(
            roleA: primaryContainer,
            roleB: primary,
            delta: 5.0,
            polarity: .relativeLighter,
            constraint: .farther,
          )
        : null,
  );
  return super.primary.extendSpecVersion(SpecVersion.spec2025, color2025);
}