Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit ee5561a

Browse files
committed
feat: move previous camera controller dispose to finally in case of an uncaught exception
1 parent 0a86ac8 commit ee5561a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,13 +636,13 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
636636
]);
637637
} on CameraException catch (e) {
638638
_showCameraException(e);
639-
}
639+
} finally {
640+
if (mounted) {
641+
setState(() {});
642+
}
640643

641-
if (mounted) {
642-
setState(() {});
644+
await previousCameraController?.dispose();
643645
}
644-
645-
await previousCameraController?.dispose();
646646
}
647647

648648
void onTakePictureButtonPressed() {

0 commit comments

Comments
 (0)