From 83cf44ed124146bcdcdea084edd04a9259c93d8a Mon Sep 17 00:00:00 2001 From: Nishant Kumar <148634283+nikkivirtuoso@users.noreply.github.com> Date: Tue, 9 Jan 2024 23:49:07 +0530 Subject: [PATCH] resolved the issue of indeterminate CircularProgressIndicator.adaptive on Darwin (#140947) Fixes #140574 Passes the value from `CircularProgressIndicator` to the Cupertino version so that functionality is not lost on Apple devices. --- .../lib/src/material/progress_indicator.dart | 13 ++++++++- .../material/progress_indicator_test.dart | 28 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/progress_indicator.dart b/packages/flutter/lib/src/material/progress_indicator.dart index 2a1cfa80e8..160293c03a 100644 --- a/packages/flutter/lib/src/material/progress_indicator.dart +++ b/packages/flutter/lib/src/material/progress_indicator.dart @@ -705,7 +705,18 @@ class _CircularProgressIndicatorState extends State w Widget _buildCupertinoIndicator(BuildContext context) { final Color? tickColor = widget.backgroundColor; - return CupertinoActivityIndicator(key: widget.key, color: tickColor); + final double? value = widget.value; + if (value == null) { + return CupertinoActivityIndicator( + key: widget.key, + color: tickColor + ); + } + return CupertinoActivityIndicator.partiallyRevealed( + key: widget.key, + color: tickColor, + progress: value + ); } Widget _buildMaterialIndicator(BuildContext context, double headValue, double tailValue, double offsetValue, double rotationValue) { diff --git a/packages/flutter/test/material/progress_indicator_test.dart b/packages/flutter/test/material/progress_indicator_test.dart index c084e290d9..2d06e7b3af 100644 --- a/packages/flutter/test/material/progress_indicator_test.dart +++ b/packages/flutter/test/material/progress_indicator_test.dart @@ -1084,6 +1084,34 @@ void main() { }), ); + testWidgets( + 'Adaptive CircularProgressIndicator displays CupertinoActivityIndicator in iOS/macOS', + (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(), + home: const Scaffold( + body: Material( + child: CircularProgressIndicator.adaptive( + value: 0.5, + ), + ), + ), + ), + ); + + expect(find.byType(CupertinoActivityIndicator), findsOneWidget); + final double actualProgress = tester.widget( + find.byType(CupertinoActivityIndicator), + ).progress; + expect(actualProgress, 0.5); + }, + variant: const TargetPlatformVariant( { + TargetPlatform.iOS, + TargetPlatform.macOS, + }), + ); + testWidgets( 'Adaptive CircularProgressIndicator can use backgroundColor to change tick color for iOS', (WidgetTester tester) async {