paint method

  1. @override
void paint(
  1. PaintingContext context,
  2. Offset center,
  3. {required Animation<double> activationAnimation,
  4. required Animation<double> enableAnimation,
  5. bool? isDiscrete,
  6. bool isOnTop = false,
  7. required TextPainter labelPainter,
  8. required RenderBox parentBox,
  9. required SliderThemeData sliderTheme,
  10. TextDirection? textDirection,
  11. Thumb? thumb,
  12. double? value,
  13. double? textScaleFactor,
  14. Size? sizeWithOverflow}

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 usually comes from MediaQueryData.textScaleFactor.

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).


void paint(
  PaintingContext context,
  Offset center, {
  required Animation<double> activationAnimation,
  required Animation<double> enableAnimation,
  bool? isDiscrete,
  bool isOnTop = false,
  required TextPainter labelPainter,
  required RenderBox parentBox,
  required SliderThemeData sliderTheme,
  TextDirection? textDirection,
  Thumb? thumb,
  double? value,
  double? textScaleFactor,
  Size? sizeWithOverflow,
}) {
  final ColorTween enableColor = ColorTween(
    begin: sliderTheme.disabledThumbColor,
    end: sliderTheme.valueIndicatorColor,
  // Add a stroke of 1dp around the top paddle.
    Paint()..color = enableColor.evaluate(enableAnimation)!,
    isOnTop ? sliderTheme.overlappingShapeStrokeColor : null,