Skip to content

Commit 3234a2b

Browse files
committed
[camera_avfoundation] Disable camera selection during recording
Disables the `RadioListTile` widgets for camera selection while a video is being recorded. This prevents the user from attempting to switch cameras during a recording session, which is not a supported action.
1 parent 6c5c615 commit 3234a2b

File tree

1 file changed

+13
-15
lines changed
  • packages/camera/camera_avfoundation/example/lib

1 file changed

+13
-15
lines changed

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

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -584,28 +584,26 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
584584
showInSnackBar('No camera found.');
585585
});
586586
return const Text('None');
587-
} else {
588-
for (final CameraDescription cameraDescription in _cameras) {
589-
toggles.add(
590-
SizedBox(
591-
width: 90.0,
592-
child: RadioListTile<CameraDescription>(
593-
title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
594-
value: cameraDescription,
595-
),
596-
),
597-
);
598-
}
599587
}
600588

601589
final bool isRecording = controller?.value.isRecordingVideo ?? false;
602590

591+
for (final CameraDescription cameraDescription in _cameras) {
592+
toggles.add(
593+
SizedBox(
594+
width: 90.0,
595+
child: RadioListTile<CameraDescription>(
596+
title: Icon(getCameraLensIcon(cameraDescription.lensDirection)),
597+
value: cameraDescription,
598+
enabled: !isRecording,
599+
),
600+
),
601+
);
602+
}
603+
603604
return RadioGroup<CameraDescription>(
604605
groupValue: controller?.description,
605606
onChanged: (CameraDescription? description) {
606-
if (isRecording) {
607-
return;
608-
}
609607
if (description != null) {
610608
onNewCameraSelected(description);
611609
}

0 commit comments

Comments
 (0)