Created
July 29, 2022 09:20
-
-
Save BarryDaBee/57b89eaa6a243ed351ae031814970106 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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