Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
🔥 Remove condition and add comments
  • Loading branch information
AlexV525 committed May 20, 2022
commit 89ff1447ac136dfc3a3e79d4db742ebb0ad4e1a9
11 changes: 5 additions & 6 deletions packages/camera/camera/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -665,12 +665,6 @@ class _CameraExampleHomeState extends State<CameraExampleHome>

try {
await cameraController.initialize();
if (cameraController.value.hasError) {
showInSnackBar(
'Camera error ${cameraController.value.errorDescription}',
);
return;
}
await Future.wait(<Future<Object?>>[
// The exposure mode is currently not supported on the web.
if (kIsWeb) ...<Future<Object?>>[
Expand All @@ -688,6 +682,11 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
.getMinZoomLevel()
.then((double value) => _minAvailableZoom = value),
]);
// `controller` needs to be set until it's fully initialized, to avoid a
// race condition when the lifecycle callback being called and creates a
// new `controller`. This happens when the camera permission dialog
// dismisses at the first run, which triggers `didChangeAppLifecycleState`
// that disposes and re-creates the controller.
controller = cameraController;
} on CameraException catch (e) {
switch (e.code) {
Expand Down