get method

int get(
  1. int tone
)

Returns the ARGB representation of an HCT color.

If the class was instantiated from _hue and _chroma, will return the color with corresponding tone. If the class was instantiated from a fixed-size list of color ints, tone must be in commonTones.

Implementation

int get(int tone) {
  if (_hue == null || _chroma == null) {
    if (!_cache.containsKey(tone)) {
      throw ArgumentError.value(
        tone,
        'tone',
        'When a TonalPalette is created with fromList, tone must be one of '
            '$commonTones',
      );
    } else {
      return _cache[tone]!;
    }
  }
  final double chroma = (tone >= 90.0) ? math.min(_chroma!, 40.0) : _chroma!;
  return _cache.putIfAbsent(
      tone, () => Hct.from(_hue!, chroma, tone.toDouble()).toInt());
}