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