gradient property
gradient
Implementation
Gradient? get gradient => $def(() {
final List<Color> colors;
final gradient = $get(#gradient);
final fillStart = gradientStart ?? Alignment.topLeft;
final fillEnd = gradientEnd ?? -fillStart;
if (gradient != null) return gradient;
if (this.colors.isEmpty) return null;
if (this.colors.length > 1) {
colors = this.colors;
} else {
colors = [this.colors.first] * 2;
}
if (gradientStyle == GradientStyle.sweep) {
return SweepGradient(
colors: colors,
stops: stops,
center: (fillEnd - fillStart) / 2,
);
} else if (gradientStyle == GradientStyle.radial) {
return RadialGradient(
colors: colors,
stops: stops,
center: (fillEnd - fillStart) / 2,
focal: fillEnd,
radius: 1.0,
);
} else {
return LinearGradient(
colors: colors,
stops: stops,
begin: fillStart,
end: fillEnd,
);
}
});
Implementation
set gradient(Gradient? gradient) => $set(#gradient, gradient);