Skip to content

Commit 71512cd

Browse files
authored
[CircularPercentIndicator] Fix resizing issue (#231)
1 parent 2446a32 commit 71512cd

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/circular_percent_indicator.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class _CircularPercentIndicatorState extends State<CircularPercentIndicator>
214214
} else {
215215
_updateProgress();
216216
}
217-
_diameter = widget.radius * 2;
217+
_calculateDiameter();
218218
super.initState();
219219
}
220220

@@ -229,6 +229,11 @@ class _CircularPercentIndicatorState extends State<CircularPercentIndicator>
229229
@override
230230
void didUpdateWidget(CircularPercentIndicator oldWidget) {
231231
super.didUpdateWidget(oldWidget);
232+
233+
if (oldWidget.radius != widget.radius) {
234+
_calculateDiameter();
235+
}
236+
232237
if (oldWidget.percent != widget.percent ||
233238
oldWidget.startAngle != widget.startAngle) {
234239
if (_animationController != null) {
@@ -248,10 +253,14 @@ class _CircularPercentIndicatorState extends State<CircularPercentIndicator>
248253
_checkIfNeedCancelAnimation(oldWidget);
249254
}
250255

251-
_updateProgress() {
256+
void _updateProgress() {
252257
setState(() => _percent = widget.percent);
253258
}
254259

260+
void _calculateDiameter() {
261+
_diameter = widget.radius * 2;
262+
}
263+
255264
@override
256265
Widget build(BuildContext context) {
257266
super.build(context);

0 commit comments

Comments
 (0)