Skip to content

Instantly share code, notes, and snippets.

@BarryDaBee
Created July 29, 2022 09:20
Show Gist options
  • Select an option

  • Save BarryDaBee/57b89eaa6a243ed351ae031814970106 to your computer and use it in GitHub Desktop.

Select an option

Save BarryDaBee/57b89eaa6a243ed351ae031814970106 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
class CustomThumbShape extends SliderComponentShape {
final double thumbRadius;
const CustomThumbShape({
required this.thumbRadius,
});
@override
Size getPreferredSize(bool isEnabled, bool isDiscrete) {
return Size.fromRadius(thumbRadius);
}
@override
void paint(PaintingContext context, Offset center, {required Animation<double> activationAnimation, required Animation<double> enableAnimation, required bool isDiscrete, required TextPainter labelPainter, required RenderBox parentBox, required SliderThemeData sliderTheme, required TextDirection textDirection, required double value, required double textScaleFactor, required Size sizeWithOverflow}) {
final canvas = context.canvas;
final fillPaint = Paint()
..color = Colors.white
..style = PaintingStyle.fill;
final borderPaint = Paint()
..color = Colors.blue
..strokeWidth = 3
..style = PaintingStyle.stroke;
canvas..drawCircle(center, thumbRadius, fillPaint)
..drawCircle(center, thumbRadius, borderPaint);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment