drawCenterCircle method
void
drawCenterCircle(
- Canvas canvas,
- bool isAnimating
)
Implementation
void drawCenterCircle(Canvas canvas, bool isAnimating) {
solidColorPaint.color = centreCircleBackgroundColor;
canvas.drawArc(centerCircleRectF, 0, 2 * math.pi, true, solidColorPaint);
if (!isAnimating) {
if (viewStyle != ViewStyle.DOMINANT_WHITE) {
final titleTextSpan = TextSpan(
text: "${overallPct.toInt()}%\n",
style: centreCirclePercentageTextStyle,
);
final subtitleTextSpan = TextSpan(
text: centreCircleTitle,
style: centreCircleSubtitleTextStyle,
);
final textPainter = TextPainter(
textAlign: TextAlign.center,
text: TextSpan(children: [titleTextSpan, subtitleTextSpan]),
textDirection: TextDirection.ltr,
);
textPainter.layout();
final x = canvasCx - (textPainter.width / 2);
final y = canvasCy - (textPainter.height / 2);
textPainter.paint(canvas, Offset(x, y));
} else {
final textSpan = TextSpan(
text: "${overallPct.toInt()}%\n",
style: centreCirclePercentageTextStyle,
);
final subtitleTextSpan = TextSpan(
text: centreCircleTitle,
style: centreCircleSubtitleTextStyle,
);
final textPainter = TextPainter(
textAlign: TextAlign.center,
text: TextSpan(children: [textSpan, subtitleTextSpan]),
textDirection: TextDirection.ltr,
);
textPainter.layout();
final x = canvasCx - (textPainter.width / 2);
final y = canvasCy - (textPainter.height / 2);
final offset = Offset(x, y);
textPainter.paint(canvas, offset);
}
}
}