get method
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 if palette type is FlexPaletteType.common and
in extendedTones if palette type is FlexPaletteType.extended.
Implementation
int get(int tone) {
if (_hue == null || _chroma == null) {
if (!_cache.containsKey(tone)) {
throw ArgumentError.value(
tone,
'tone',
'When a FlexTonalPalette is created with fromList using '
'$_paletteType, tone must be one of '
// ignore: lines_longer_than_80_chars
'${_paletteType == FlexPaletteType.common ? commonTones : extendedTones}.',
);
} else {
return _cache[tone]!;
}
}
// If we are using `common` tonal palette type and the tone is larger or
// equal to 90, allow maximum chroma value of 90, in other cases
// use the actual chroma value.
final double chroma =
(tone >= 90.0) && _paletteType == FlexPaletteType.common
? math.min(_chroma!, 40.0)
: _chroma!;
return _cache.putIfAbsent(
tone, () => Hct.from(_hue!, chroma, tone.toDouble()).toInt());
}