paint method

  1. @override
Future<void> paint(
  1. PaintingContext context,
  2. Offset center, {
  3. required RenderBox parentBox,
  4. required SliderThemeData sliderTheme,
  5. required Animation<double> enableAnimation,
  6. required TextDirection textDirection,
  7. required Offset thumbCenter,
  8. required bool isEnabled,
})
override

paint method

Implementation

@override
Future<void> paint(
  PaintingContext context,
  Offset center, {
  required RenderBox parentBox,
  required SliderThemeData sliderTheme,
  required Animation<double> enableAnimation,
  required TextDirection textDirection,
  required Offset thumbCenter,
  required bool isEnabled,
}) async {
  switch (textDirection) {
    case TextDirection.ltr:
      break;
    case TextDirection.rtl:
      break;
  }

  /// array to store index
  if (canvasXIndex.length != images.length) {
    canvasXIndex.add(center.dx);
  }

  /// tick mark radius
  final double tickMarkRadius = getPreferredSize(
        isEnabled: isEnabled,
        sliderTheme: sliderTheme,
      ).width /
      3;

  if (tickMarkRadius > 0) {
    int index = 0;
    for (var element in canvasXIndex) {
      if (element == center.dx) {
        break;
      }
      index++;
    }

    try {
      /// draw image
      if (images.isNotEmpty) {
        Paint paint = Paint()..color = Colors.green;
        context.canvas.save();
        context.canvas.drawImage(images[index],
            Offset(center.dx - 18, labelDirection == AssetDirection.below ? center.dy + 18 : center.dy - 48), paint);
        context.canvas.restore();
      }
    } catch (exception) {
      return;
    }
  }
}