File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
packages/camera/camera/lib/src Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -376,7 +376,13 @@ class CameraController extends ValueNotifier<CameraValue> {
376
376
.then ((CameraInitializedEvent event) => event.focusPointSupported),
377
377
);
378
378
} on PlatformException catch (e) {
379
+ _unawaited (_deviceOrientationSubscription? .cancel ());
380
+ _cameraId = kUninitializedCameraId;
379
381
throw CameraException (e.code, e.message);
382
+ } catch (e) {
383
+ _unawaited (_deviceOrientationSubscription? .cancel ());
384
+ _cameraId = kUninitializedCameraId;
385
+ rethrow ;
380
386
} finally {
381
387
initializeCompleter.complete ();
382
388
}
@@ -880,8 +886,10 @@ class CameraController extends ValueNotifier<CameraValue> {
880
886
_unawaited (_deviceOrientationSubscription? .cancel ());
881
887
_isDisposed = true ;
882
888
super .dispose ();
883
- if (_initializeFuture != null ) {
884
- await _initializeFuture;
889
+ if (_initializeFuture == null ) {
890
+ return ;
891
+ }
892
+ if (_cameraId != kUninitializedCameraId) {
885
893
await CameraPlatform .instance.dispose (_cameraId);
886
894
}
887
895
}
You can’t perform that action at this time.
0 commit comments