Skip to content

[various] Use RadioGroup for groupValue and onChanged #9467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/animations/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT

* Uses `RadioGroup` for `groupValue` and `onChanged`.
* Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.

## 2.0.11
Expand Down
50 changes: 22 additions & 28 deletions packages/animations/example/lib/shared_axis_transition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,34 +76,28 @@ class _SharedAxisTransitionDemoState extends State<SharedAxisTransitionDemo> {
),
),
const Divider(thickness: 2.0),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Radio<SharedAxisTransitionType>(
value: SharedAxisTransitionType.horizontal,
groupValue: _transitionType,
onChanged: (SharedAxisTransitionType? newValue) {
_updateTransitionType(newValue);
},
),
const Text('X'),
Radio<SharedAxisTransitionType>(
value: SharedAxisTransitionType.vertical,
groupValue: _transitionType,
onChanged: (SharedAxisTransitionType? newValue) {
_updateTransitionType(newValue);
},
),
const Text('Y'),
Radio<SharedAxisTransitionType>(
value: SharedAxisTransitionType.scaled,
groupValue: _transitionType,
onChanged: (SharedAxisTransitionType? newValue) {
_updateTransitionType(newValue);
},
),
const Text('Z'),
],
RadioGroup<SharedAxisTransitionType>(
groupValue: _transitionType,
onChanged: (SharedAxisTransitionType? newValue) {
_updateTransitionType(newValue);
},
child: const Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Radio<SharedAxisTransitionType>(
value: SharedAxisTransitionType.horizontal,
),
Text('X'),
Radio<SharedAxisTransitionType>(
value: SharedAxisTransitionType.vertical,
),
Text('Y'),
Radio<SharedAxisTransitionType>(
value: SharedAxisTransitionType.scaled,
),
Text('Z'),
],
),
),
],
),
Expand Down
3 changes: 2 additions & 1 deletion packages/camera/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.11.1+1

* Uses `RadioGroup` for `groupValue` and `onChanged`.
* Fixes overflowed toggles in the camera example.

## 0.11.1
Expand Down
8 changes: 5 additions & 3 deletions packages/camera/camera/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
width: 90.0,
child: RadioListTile<CameraDescription>(
title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
groupValue: controller?.description,
value: cameraDescription,
onChanged: onChanged,
),
),
);
Expand All @@ -591,7 +589,11 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
return Expanded(
child: SizedBox(
height: 56.0,
child: ListView(scrollDirection: Axis.horizontal, children: toggles),
child: RadioGroup<CameraDescription>(
groupValue: controller?.description,
onChanged: onChanged,
child: ListView(scrollDirection: Axis.horizontal, children: toggles),
),
),
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing
Dart.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.11.1
version: 0.11.1+1

environment:
sdk: ^3.6.0
Expand Down
4 changes: 4 additions & 0 deletions packages/camera/camera_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.10+4

* Uses `RadioGroup` for `groupValue` and `onChanged`.

## 0.10.10+3

* Waits for the creation of the capture session when initializing the camera to avoid thread race conditions.
Expand Down
8 changes: 5 additions & 3 deletions packages/camera/camera_android/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -591,16 +591,18 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
width: 90.0,
child: RadioListTile<CameraDescription>(
title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
groupValue: controller?.description,
value: cameraDescription,
onChanged: onChanged,
),
),
);
}
}

return Row(children: toggles);
return RadioGroup<CameraDescription>(
groupValue: controller?.description,
onChanged: onChanged,
child: Row(children: toggles),
);
}

String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Android implementation of the camera plugin.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22

version: 0.10.10+3
version: 0.10.10+4

environment:
sdk: ^3.6.0
Expand Down
4 changes: 4 additions & 0 deletions packages/camera/camera_android_camerax/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.18+4

* Uses `RadioGroup` for `groupValue` and `onChanged`.

## 0.6.18+3

* Fixes incorrect camera preview mirroring for front cameras of devices using the Impeller backend.
Expand Down
15 changes: 9 additions & 6 deletions packages/camera/camera_android_camerax/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,10 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
return;
}

if (controller != null && controller!.value.isRecordingVideo) {
return;
}

onNewCameraSelected(description);
}

Expand All @@ -609,19 +613,18 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
width: 90.0,
child: RadioListTile<CameraDescription>(
title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
groupValue: controller?.description,
value: cameraDescription,
onChanged:
controller != null && controller!.value.isRecordingVideo
? null
: onChanged,
),
),
);
}
}

return Row(children: toggles);
return RadioGroup<CameraDescription>(
groupValue: controller?.description,
onChanged: onChanged,
child: Row(children: toggles),
);
}

String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_android_camerax/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_android_camerax
description: Android implementation of the camera plugin using the CameraX library.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.6.18+3
version: 0.6.18+4

environment:
sdk: ^3.7.0
Expand Down
4 changes: 4 additions & 0 deletions packages/camera/camera_avfoundation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.20+2

* Uses `RadioGroup` for `groupValue` and `onChanged`.

## 0.9.20+1

* Migrates lifecycle methods (`start`, `stop`, `close`) to Swift.
Expand Down
14 changes: 9 additions & 5 deletions packages/camera/camera_avfoundation/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
return;
}

if (controller?.value.isRecordingVideo ?? false) {
return;
}

onNewCameraSelected(description);
}

Expand All @@ -591,18 +595,18 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
width: 90.0,
child: RadioListTile<CameraDescription>(
title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
groupValue: controller?.description,
value: cameraDescription,
onChanged: (controller?.value.isRecordingVideo ?? false)
? null
: onChanged,
),
),
);
}
}

return Row(children: toggles);
return RadioGroup<CameraDescription>(
groupValue: controller?.description,
onChanged: onChanged,
child: Row(children: toggles),
);
}

String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_avfoundation/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_avfoundation
description: iOS implementation of the camera plugin.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_avfoundation
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.9.20+1
version: 0.9.20+2

environment:
sdk: ^3.6.0
Expand Down
1 change: 1 addition & 0 deletions packages/google_sign_in/google_sign_in_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT

* Uses `RadioGroup` for `groupValue` and `onChanged`.
* Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.

## 0.12.4+4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,22 @@ Widget _renderRadioListTileCard<T extends Enum>({
required String title,
required List<T> values,
T? selected,
void Function(T?)? onChanged,
required void Function(T?) onChanged,
}) {
return _renderConfigCard(
title: title,
children: values
.map((T value) => RadioListTile<T>(
value: value,
groupValue: selected,
onChanged: onChanged,
selected: value == selected,
title: Text(value.name),
dense: true,
))
.toList());
return RadioGroup<T>(
groupValue: selected,
onChanged: onChanged,
child: _renderConfigCard(
title: title,
children: values
.map((T value) => RadioListTile<T>(
value: value,
selected: value == selected,
title: Text(value.name),
dense: true,
))
.toList()),
);
}

/// Renders a Card where we render some `children` that change config.
Expand Down Expand Up @@ -217,12 +219,12 @@ GSIButtonConfiguration _copyConfigWith<T>(
}

/// Returns a function that modifies the `current` configuration with a `value`, then calls `fn` with it.
void Function(T?)? _onChanged<T>(
void Function(T?) _onChanged<T>(
GSIButtonConfiguration? current,
OnWebConfigChangeFn? fn,
) {
if (fn == null) {
return null;
return (_) {};
}
return (T? value) {
fn(_copyConfigWith<T>(current, value));
Expand Down
4 changes: 4 additions & 0 deletions packages/two_dimensional_scrollables/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## NEXT

* Uses `RadioGroup` for `groupValue` and `onChanged`.

## 0.3.6

* Fixes typo in API docs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,45 +51,35 @@ class _TableExplorerState extends State<TableExplorer> {
}

Widget _getRadioRow() {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
const Spacer(),
Radio<TableType>(
value: TableType.simple,
groupValue: _currentExample,
onChanged: (TableType? value) {
setState(() {
_currentExample = value!;
});
},
),
const Text('Simple'),
_spacer,
Radio<TableType>(
value: TableType.merged,
groupValue: _currentExample,
onChanged: (TableType? value) {
setState(() {
_currentExample = value!;
});
},
),
const Text('Merged'),
_spacer,
Radio<TableType>(
value: TableType.infinite,
groupValue: _currentExample,
onChanged: (TableType? value) {
setState(() {
_currentExample = value!;
});
},
),
const Text('Infinite'),
const Spacer(),
],
return RadioGroup<TableType>(
groupValue: _currentExample,
onChanged: (TableType? value) {
setState(() {
_currentExample = value!;
});
},
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: <Widget>[
const Spacer(),
const Radio<TableType>(
value: TableType.simple,
),
const Text('Simple'),
_spacer,
const Radio<TableType>(
value: TableType.merged,
),
const Text('Merged'),
_spacer,
const Radio<TableType>(
value: TableType.infinite,
),
const Text('Infinite'),
const Spacer(),
],
),
),
);
}
Expand Down
Loading