Last active
October 16, 2022 19:30
-
-
Save ValeryPonomarenko/f174c8608af61bde708cde9fa69ca9ef to your computer and use it in GitHub Desktop.
This file contains 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
class HalfCircleProgressBar extends StatelessWidget { | |
const HalfCircleProgressBar({ | |
Key? key, | |
required this.progress, | |
required this.dotColor, | |
required this.progressDotColor, | |
this.dotRadius = _defaultDotRadius, | |
this.startBarRadius = _defaultStartBarRadius, | |
this.layers = _defaultLayers, | |
this.layersSpacing = _defaultLayersSpacing, | |
this.dotsSpacing = _defaultDotsSpacing, | |
}) : super(key: key); | |
final double progress; | |
final double dotRadius; | |
final double startBarRadius; | |
final int layers; | |
final double layersSpacing; | |
final double dotsSpacing; | |
final Color dotColor; | |
final Color progressDotColor; | |
static const _defaultDotRadius = 4.0; | |
static const _defaultStartBarRadius = 68.0; | |
static const _defaultLayers = 10; | |
static const _defaultLayersSpacing = 1.0; | |
static const _defaultDotsSpacing = 1.0; | |
@override | |
Widget build(BuildContext context) { | |
final height = startBarRadius + (layersSpacing + dotRadius * 2) * layers; | |
return ClipRect( | |
child: CustomPaint( | |
size: Size(height * 2, height), | |
painter: _DiagramPainter( | |
dotRadius: dotRadius, | |
startBarRadius: startBarRadius, | |
layers: layers, | |
layersSpacing: layersSpacing, | |
dotsSpacing: dotsSpacing, | |
progress: progress, | |
dotColor: dotColor, | |
progressDotColor: progressDotColor, | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment