Skip to content

Commit f6896e5

Browse files
authored
[various] Migrate example Radio groups to new RadioGroup API (#10155)
This PR updates multiple package **example** apps to stop using deprecated `groupValue` and `onChanged` on individual `Radio` widgets and instead use the new `RadioGroup<T>` ancestor to manage the selected value and change handling. ### Why Flutter deprecated `Radio.groupValue` and `Radio.onChanged` in favor of `RadioGroup`, which centralizes selection state for related radios. The deprecation is currently reported across several examples in this repo (see linked issue for examples and affected packages). This PR resolves those warnings. ### What changed (pattern applied across examples) - Wrap related `Radio<T>` widgets in a `RadioGroup<T>(groupValue: ..., onChanged: ...)`. - Remove `groupValue`/`onChanged` from each `Radio`, leaving only `value` (+ its label UI). - Example (from `animations` demo): old three `Radio` widgets each had `groupValue`/`onChanged`; now they are enclosed in a single `RadioGroup<SharedAxisTransitionType>` and the `Radio` children keep just their `value`. ### Packages (examples) updated - `animations` - `camera` - `camera_android` - `camera_android_camerax` - `camera_avfoundation` - `google_sign_in_web` - `two_dimensional_scrollables` (both `table_view` and `tree_view`) ### Screenshots N/A (UI unchanged; only wiring of radios changed). ### Links Fixes: [flutter/flutter#170915](flutter/flutter#170915) --- ## Pre-Review Checklist
1 parent ce0b99c commit f6896e5

File tree

18 files changed

+132
-124
lines changed

18 files changed

+132
-124
lines changed

packages/animations/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## 2.1.0
22

3+
* Updates examples to use the new RadioGroup API instead of deprecated Radio parameters.
34
* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.
45
* Make `OpenContainerState` public.
56

packages/animations/example/lib/shared_axis_transition.dart

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -76,34 +76,28 @@ class _SharedAxisTransitionDemoState extends State<SharedAxisTransitionDemo> {
7676
),
7777
),
7878
const Divider(thickness: 2.0),
79-
Row(
80-
mainAxisAlignment: MainAxisAlignment.center,
81-
children: <Widget>[
82-
Radio<SharedAxisTransitionType>(
83-
value: SharedAxisTransitionType.horizontal,
84-
groupValue: _transitionType,
85-
onChanged: (SharedAxisTransitionType? newValue) {
86-
_updateTransitionType(newValue);
87-
},
88-
),
89-
const Text('X'),
90-
Radio<SharedAxisTransitionType>(
91-
value: SharedAxisTransitionType.vertical,
92-
groupValue: _transitionType,
93-
onChanged: (SharedAxisTransitionType? newValue) {
94-
_updateTransitionType(newValue);
95-
},
96-
),
97-
const Text('Y'),
98-
Radio<SharedAxisTransitionType>(
99-
value: SharedAxisTransitionType.scaled,
100-
groupValue: _transitionType,
101-
onChanged: (SharedAxisTransitionType? newValue) {
102-
_updateTransitionType(newValue);
103-
},
104-
),
105-
const Text('Z'),
106-
],
79+
RadioGroup<SharedAxisTransitionType>(
80+
groupValue: _transitionType,
81+
onChanged: (SharedAxisTransitionType? newValue) {
82+
_updateTransitionType(newValue);
83+
},
84+
child: const Row(
85+
mainAxisAlignment: MainAxisAlignment.center,
86+
children: <Widget>[
87+
Radio<SharedAxisTransitionType>(
88+
value: SharedAxisTransitionType.horizontal,
89+
),
90+
Text('X'),
91+
Radio<SharedAxisTransitionType>(
92+
value: SharedAxisTransitionType.vertical,
93+
),
94+
Text('Y'),
95+
Radio<SharedAxisTransitionType>(
96+
value: SharedAxisTransitionType.scaled,
97+
),
98+
Text('Z'),
99+
],
100+
),
107101
),
108102
],
109103
),

packages/camera/camera/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 0.11.2+1
22

3+
* Updates examples to use the new RadioGroup API instead of deprecated Radio parameters.
34
* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.
45
* Updates README to reflect that only Android API 24+ is supported.
56

packages/camera/camera/example/lib/main.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
598598
width: 90.0,
599599
child: RadioListTile<CameraDescription>(
600600
title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
601-
groupValue: controller?.description,
602601
value: cameraDescription,
603-
onChanged: onChanged,
604602
),
605603
),
606604
);
@@ -610,7 +608,11 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
610608
return Expanded(
611609
child: SizedBox(
612610
height: 56.0,
613-
child: ListView(scrollDirection: Axis.horizontal, children: toggles),
611+
child: RadioGroup<CameraDescription>(
612+
groupValue: controller?.description,
613+
onChanged: onChanged,
614+
child: ListView(scrollDirection: Axis.horizontal, children: toggles),
615+
),
614616
),
615617
);
616618
}

packages/camera/camera/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing
44
Dart.
55
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera
66
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
7-
version: 0.11.2
7+
version: 0.11.2+1
88

99
environment:
1010
sdk: ^3.7.0

packages/camera/camera_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.10.10+11
2+
3+
* Updates examples to use the new RadioGroup API instead of deprecated Radio parameters.
4+
15
## 0.10.10+10
26

37
* Updates Java compatibility version to 17.

packages/camera/camera_android/example/lib/main.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -599,16 +599,18 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
599599
width: 90.0,
600600
child: RadioListTile<CameraDescription>(
601601
title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
602-
groupValue: controller?.description,
603602
value: cameraDescription,
604-
onChanged: onChanged,
605603
),
606604
),
607605
);
608606
}
609607
}
610608

611-
return Row(children: toggles);
609+
return RadioGroup<CameraDescription>(
610+
groupValue: controller?.description,
611+
onChanged: onChanged,
612+
child: Row(children: toggles),
613+
);
612614
}
613615

614616
String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();

packages/camera/camera_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Android implementation of the camera plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
55

6-
version: 0.10.10+10
6+
version: 0.10.10+11
77

88
environment:
99
sdk: ^3.9.0

packages/camera/camera_android_camerax/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.23+4
2+
3+
* Updates examples to use the new RadioGroup API instead of deprecated Radio parameters.
4+
15
## 0.6.23+3
26

37
* Bumps camerax_version from 1.5.0 to 1.5.1.

packages/camera/camera_android_camerax/example/lib/main.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,16 +590,18 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
590590
width: 90.0,
591591
child: RadioListTile<CameraDescription>(
592592
title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
593-
groupValue: controller?.description,
594593
value: cameraDescription,
595-
onChanged: onChanged,
596594
),
597595
),
598596
);
599597
}
600598
}
601599

602-
return Row(children: toggles);
600+
return RadioGroup<CameraDescription>(
601+
groupValue: controller?.description,
602+
onChanged: onChanged,
603+
child: Row(children: toggles),
604+
);
603605
}
604606

605607
String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();

0 commit comments

Comments
 (0)