DynamicColor.fromArgb constructor

DynamicColor.fromArgb(
  1. String name,
  2. int argb
)

Create a DynamicColor from a hex code.

Result has no background; thus no support for increasing/decreasing contrast for a11y.

  • name - The name of the dynamic color.
  • argb - The source color from which to extract the hue and chroma.

Implementation

factory DynamicColor.fromArgb(String name, int argb) {
  final hct = Hct.fromInt(argb);
  final palette = TonalPalette.fromInt(argb);
  return DynamicColor(
    name: name,
    palette: (_) => palette,
    tone: (_) => hct.tone,
  );
}