From a2d1d27f79674adb85773d6b836b2034dfa4bdc4 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Tue, 29 May 2018 18:04:13 -0700 Subject: [PATCH] Keep indeterminate RefreshProgressIndicator spinning until end of time (#18010) --- .../lib/src/material/progress_indicator.dart | 4 +-- .../material/progress_indicator_test.dart | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/flutter/lib/src/material/progress_indicator.dart b/packages/flutter/lib/src/material/progress_indicator.dart index 7eb14b4a29..f39506b84f 100644 --- a/packages/flutter/lib/src/material/progress_indicator.dart +++ b/packages/flutter/lib/src/material/progress_indicator.dart @@ -528,8 +528,8 @@ class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState { Widget build(BuildContext context) { if (widget.value != null) _controller.value = widget.value / 10.0; - else - _controller.forward(); + else if (!_controller.isAnimating) + _controller.repeat(); return _buildAnimation(); } diff --git a/packages/flutter/test/material/progress_indicator_test.dart b/packages/flutter/test/material/progress_indicator_test.dart index bfdc3183ad..e9c03fbb04 100644 --- a/packages/flutter/test/material/progress_indicator_test.dart +++ b/packages/flutter/test/material/progress_indicator_test.dart @@ -206,4 +206,30 @@ void main() { expect(find.byType(CircularProgressIndicator), paints..arc(strokeWidth: 16.0)); }); + testWidgets('Indeterminate RefreshProgressIndicator keeps spinning until end of time (approximate)', (WidgetTester tester) async { + // Regression test for https://github.com/flutter/flutter/issues/13782 + + await tester.pumpWidget( + const Directionality( + textDirection: TextDirection.ltr, + child: const Center( + child: const SizedBox( + width: 200.0, + child: const RefreshProgressIndicator(), + ), + ), + ), + ); + expect(tester.hasRunningAnimations, isTrue); + + await tester.pump(const Duration(milliseconds: 6666)); + expect(tester.hasRunningAnimations, isTrue); + + await tester.pump(const Duration(milliseconds: 1)); + expect(tester.hasRunningAnimations, isTrue); + + await tester.pump(const Duration(days: 9999)); + expect(tester.hasRunningAnimations, isTrue); + }); + }