paint method
- PaintingContext context,
- Offset center, {
- Animation<
double> ? activationAnimation, - Animation<
double> ? enableAnimation, - bool? isDiscrete,
- bool? isOnTop,
- TextPainter? labelPainter,
- double? textScaleFactor,
- Size? sizeWithOverflow,
- RenderBox? parentBox,
- SliderThemeData? sliderTheme,
- TextDirection? textDirection,
- double? value,
- Thumb? thumb,
Paints the value indicator shape based on the state passed to it.
The context
argument represents the RangeSlider's render box.
The center
argument is the offset for where this shape's center should be
painted. This offset is relative to the origin of the context
canvas.
The activationAnimation
argument is an animation triggered when the user
begins to interact with the RangeSlider. It reverses when the user stops
interacting with the slider.
The enableAnimation
argument is an animation triggered when the
RangeSlider is enabled, and it reverses when the slider is disabled. The
RangeSlider is enabled when RangeSlider.onChanged is not null. Use
this to paint intermediate frames for this shape when the slider changes
enabled state.
The isDiscrete
argument is true if RangeSlider.divisions is non-null.
When true, the slider will render tick marks on top of the track.
The isOnTop
argument is the top-most value indicator between the two value
indicators, which is always the indicator for the most recently selected thumb. In
the default case, this is used to paint a stroke around the top indicator
for better visibility between the two indicators.
The textScaleFactor
argument can be used to determine whether the
component should paint larger or smaller, depending on whether
textScaleFactor
is greater than 1 for larger, and between 0 and 1 for
smaller. It's usually computed from MediaQueryData.textScaler.
The sizeWithOverflow
argument can be used to determine the bounds the
drawing of the components that are outside of the regular slider bounds.
It's the size of the box, whose center is aligned with the slider's
bounds, that the value indicators must be drawn within. Typically, it is
bigger than the slider.
The parentBox
argument is the RenderBox of the RangeSlider. Its
attributes, such as size, can be used to assist in painting this shape.
The sliderTheme
argument is the theme assigned to the RangeSlider that
this shape belongs to.
The textDirection
argument can be used to determine how any extra text
or graphics, besides the text painted by the labelPainter
should be
positioned. The labelPainter
argument already has the textDirection
set.
The value
argument is the current parametric value (from 0.0 to 1.0) of
the slider.
The thumb
argument is the specifier for which of the two thumbs this
method should paint (start or end).
Implementation
@override
void paint(
PaintingContext context,
Offset center, {
Animation<double>? activationAnimation,
Animation<double>? enableAnimation,
bool? isDiscrete,
bool? isOnTop,
TextPainter? labelPainter,
double? textScaleFactor,
Size? sizeWithOverflow,
RenderBox? parentBox,
SliderThemeData? sliderTheme,
TextDirection? textDirection,
double? value,
Thumb? thumb,
}) {
final Canvas canvas = context.canvas;
final double scale = activationAnimation!.value;
_pathPainter.paint(
parentBox: parentBox!,
canvas: canvas,
center: center,
scale: scale,
labelPainter: labelPainter!,
textScaleFactor: textScaleFactor!,
sizeWithOverflow: sizeWithOverflow!,
backgroundPaintColor: sliderTheme!.valueIndicatorColor!,
strokePaintColor: isOnTop! ? sliderTheme.overlappingShapeStrokeColor : sliderTheme.valueIndicatorStrokeColor,
);
}