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.
This commit is contained in:
@@ -705,7 +705,18 @@ class _CircularProgressIndicatorState extends State<CircularProgressIndicator> 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) {
|
||||
|
||||
@@ -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<CupertinoActivityIndicator>(
|
||||
find.byType(CupertinoActivityIndicator),
|
||||
).progress;
|
||||
expect(actualProgress, 0.5);
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform> {
|
||||
TargetPlatform.iOS,
|
||||
TargetPlatform.macOS,
|
||||
}),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Adaptive CircularProgressIndicator can use backgroundColor to change tick color for iOS',
|
||||
(WidgetTester tester) async {
|
||||
|
||||
Reference in New Issue
Block a user