Skip to content

Instantly share code, notes, and snippets.

@Indy9000
Created May 31, 2021 17:21
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 Indy9000/abf5e260a011909a534bcf6d051e64bb to your computer and use it in GitHub Desktop.
Save Indy9000/abf5e260a011909a534bcf6d051e64bb to your computer and use it in GitHub Desktop.
animated-donut-chart-06
void drawLabels(Canvas canvas, Offset c, double radius, double startAngle,
double sweepAngle, String label) {
final r = radius * 0.4;
final dx = r * cos(startAngle + sweepAngle / 2.0);
final dy = r * sin(startAngle + sweepAngle / 2.0);
final position = c + Offset(dx, dy);
drawTextCentered(canvas, position, label, labelStyle, 100.0, (Size sz) {
final rect = Rect.fromCenter(
center: position, width: sz.width + 5, height: sz.height + 5);
final rrect = RRect.fromRectAndRadius(rect, Radius.circular(5));
canvas.drawRRect(rrect, midPaint);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment