updateSegmentGradient method
void
updateSegmentGradient(
- ChartSegment segment, {
- Rect? gradientBounds,
- LinearGradient? gradient,
- LinearGradient? borderGradient,
Implementation
@nonVirtual
void updateSegmentGradient(
ChartSegment segment, {
Rect? gradientBounds,
LinearGradient? gradient,
LinearGradient? borderGradient,
}) {
segment.fillPaint.shader = null;
segment.strokePaint.shader = null;
if (!segment.isEmpty) {
if (onCreateShader != null) {
final ShaderDetails details = ShaderDetails(paintBounds, 'series');
segment.fillPaint.shader = onCreateShader!(details);
segment.strokePaint.shader = onCreateShader!(details);
} else if (gradient != null && gradientBounds != null) {
segment.fillPaint.shader = gradient.createShader(gradientBounds);
}
if (borderGradient != null && gradientBounds != null) {
// Border gradient is not working when border color is transparent.
// Hence sets series color to border color.
if (segment.strokePaint.color == Colors.transparent) {
segment.strokePaint.color = segment.fillPaint.color;
}
segment.strokePaint.shader = borderGradient.createShader(
gradientBounds.deflate(segment.strokePaint.strokeWidth / 2));
}
}
}