DynamicColor.fromPalette constructor

DynamicColor.fromPalette({
  1. String name = '',
  2. required TonalPalette palette(
    1. DynamicScheme
    ),
  3. required double tone(
    1. DynamicScheme
    ),
  4. bool isBackground = false,
  5. DynamicColor background(
    1. DynamicScheme
    )?,
  6. DynamicColor secondBackground(
    1. DynamicScheme
    )?,
  7. ContrastCurve? contrastCurve,
  8. ToneDeltaPair toneDeltaPair(
    1. DynamicScheme
    )?,
})

The convenience constructor for DynamicColor.

Similar to the base constructor, but all parameters other than palette and tone have defaults.

name The name of the dynamic color. Defaults to empty. palette Function that provides a TonalPalette given DynamicScheme. A TonalPalette is defined by a hue and chroma, so this replaces the need to specify hue/chroma. By providing a tonal palette, when contrast adjustments are made, intended chroma can be preserved. tone Function that provides a tone, given a DynamicScheme. isBackground Whether this dynamic color is a background, with some other color as the foreground. Defaults to false. background The background of the dynamic color (as a function of a DynamicScheme), if it exists. secondBackground A second background of the dynamic color (as a function of a DynamicScheme), if it exists. contrastCurve A ContrastCurve object specifying how its contrast against its background should behave in various contrast levels options. toneDeltaPair A ToneDeltaPair object specifying a tone delta constraint between two colors. One of them must be the color being constructed.

Implementation

factory DynamicColor.fromPalette({
  String name = '',
  required TonalPalette Function(DynamicScheme) palette,
  required double Function(DynamicScheme) tone,
  bool isBackground = false,
  DynamicColor Function(DynamicScheme)? background,
  DynamicColor Function(DynamicScheme)? secondBackground,
  ContrastCurve? contrastCurve,
  ToneDeltaPair Function(DynamicScheme)? toneDeltaPair,
}) {
  return DynamicColor(
    name: name,
    palette: palette,
    tone: tone,
    isBackground: isBackground,
    background: background,
    secondBackground: secondBackground,
    contrastCurve: contrastCurve,
    toneDeltaPair: toneDeltaPair,
  );
}