Skip to content

Instantly share code, notes, and snippets.

@ValeryPonomarenko
Last active October 16, 2022 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ValeryPonomarenko/f174c8608af61bde708cde9fa69ca9ef to your computer and use it in GitHub Desktop.
Save ValeryPonomarenko/f174c8608af61bde708cde9fa69ca9ef to your computer and use it in GitHub Desktop.
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