feat(ui_components): add isColor getter in multicolor helper

This commit is contained in:
Malo Léon 2023-02-16 13:25:25 +01:00
parent c6beae597b
commit f6c16c5dc4

View File

@ -23,24 +23,20 @@ class MultiColor {
final List<Color>? _colors;
final Color? _color;
Color get color {
if (_color != null) {
return _color!;
}
if (_colors?.isNotEmpty ?? false) {
return _colors!.first;
}
throw IndexError.withLength(
0,
_colors?.length ?? 0,
message: '_color is not defined or _colors is empty.',
);
}
Color get color => _color != null
? _color!
: _colors?.isNotEmpty ?? false
? _colors!.first
: throw IndexError.withLength(
0,
_colors?.length ?? 0,
message: '_color is not defined or _colors is empty.',
);
List<Color> get colors => _colors ?? [];
bool get isGradient =>
(_colors?.isNotEmpty ?? false) && (_colors?.length ?? 0) > 1;
bool get isGradient => (_colors?.length ?? 0) > 1;
bool get isColor => _color != null || isGradient;
static MultiColor? lerp(MultiColor? a, MultiColor? b, double t) {
if (a == null && b == null) {