paint method
void
paint(
- PaintingContext context,
- Offset offset,
- Offset? thumbCenter,
- Offset? startThumbCenter,
- Offset? endThumbCenter, {
- required RenderBox parentBox,
- required SfSliderThemeData themeData,
- SfRangeValues? currentValues,
- dynamic currentValue,
- required Animation<
double> enableAnimation, - required TextDirection textDirection,
Paints the major ticks based on the values passed to it.
Implementation
void paint(PaintingContext context, Offset offset, Offset? thumbCenter,
Offset? startThumbCenter, Offset? endThumbCenter,
{required RenderBox parentBox,
required SfSliderThemeData themeData,
SfRangeValues? currentValues,
dynamic currentValue,
required Animation<double> enableAnimation,
required TextDirection textDirection}) {
bool isInactive = false;
final Size tickSize = getPreferredSize(themeData);
final bool isVertical = _isVertical(parentBox as RenderBaseSlider);
if (!isVertical) {
// Added this condition to check whether consider single thumb or
// two thumbs for finding active range.
if (startThumbCenter != null) {
if (!parentBox.isInversed) {
isInactive =
offset.dx < startThumbCenter.dx || offset.dx > endThumbCenter!.dx;
} else {
isInactive =
offset.dx > startThumbCenter.dx || offset.dx < endThumbCenter!.dx;
}
} else {
if (!parentBox.isInversed) {
isInactive = offset.dx > thumbCenter!.dx;
} else {
isInactive = offset.dx < thumbCenter!.dx;
}
}
} else {
// Added this condition to check whether consider single thumb or
// two thumbs for finding active range.
if (startThumbCenter != null) {
if (!parentBox.isInversed) {
isInactive =
offset.dy > startThumbCenter.dy || offset.dy < endThumbCenter!.dy;
} else {
isInactive =
offset.dy < startThumbCenter.dy || offset.dy > endThumbCenter!.dy;
}
} else {
if (!parentBox.isInversed) {
isInactive = offset.dy < thumbCenter!.dy;
} else {
isInactive = offset.dy > thumbCenter!.dy;
}
}
}
final Color begin = isInactive
? themeData.disabledInactiveTickColor!
: themeData.disabledActiveTickColor!;
final Color end =
isInactive ? themeData.inactiveTickColor! : themeData.activeTickColor!;
final Paint paint = Paint()
..isAntiAlias = true
..strokeWidth = _isVertical(parentBox) ? tickSize.height : tickSize.width
..color = ColorTween(begin: begin, end: end).evaluate(enableAnimation)!;
if (_isVertical(parentBox)) {
context.canvas.drawLine(
offset, Offset(offset.dx + tickSize.width, offset.dy), paint);
} else {
context.canvas.drawLine(
offset, Offset(offset.dx, offset.dy + tickSize.height), paint);
}
}