Skip to content

Commit f6d50d2

Browse files
exception for unsupported platforms for camera flash
1 parent cbd4363 commit f6d50d2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

modules/camera/lib/camera.dart

+10-6
Original file line numberDiff line numberDiff line change
@@ -1234,12 +1234,16 @@ class CameraState extends EWidgetState<Camera> with WidgetsBindingObserver {
12341234
itemBuilder: (context, index) {
12351235
return IconButton(
12361236
onPressed: () {
1237-
final page = (index + 1) % flashIcons.length;
1238-
_flashPageController.animateToPage(page,
1239-
duration: const Duration(milliseconds: 400),
1240-
curve: Curves.ease);
1241-
widget._controller.cameraController
1242-
?.setFlashMode(flashModes.elementAt(page));
1237+
try{
1238+
final page = (index + 1) % flashIcons.length;
1239+
_flashPageController.animateToPage(page,
1240+
duration: const Duration(milliseconds: 400),
1241+
curve: Curves.ease);
1242+
widget._controller.cameraController
1243+
?.setFlashMode(flashModes.elementAt(page));
1244+
} catch(e){
1245+
debugPrint("CameraException: ${e}");
1246+
}
12431247
},
12441248
icon: Icon(flashIcons.elementAt(index)),
12451249
color: Colors.white);

0 commit comments

Comments
 (0)