diff --git a/lib/src/ui/reader_widget.dart b/lib/src/ui/reader_widget.dart index 38feecb..ef09215 100644 --- a/lib/src/ui/reader_widget.dart +++ b/lib/src/ui/reader_widget.dart @@ -86,6 +86,11 @@ class _ReaderWidgetState extends State @override void didChangeAppLifecycleState(AppLifecycleState state) { + final CameraController? cameraController = controller; + if (cameraController == null || !cameraController.value.isInitialized) { + return; + } + switch (state) { case AppLifecycleState.resumed: if (cameras.isNotEmpty && !_cameraOn) { @@ -93,9 +98,8 @@ class _ReaderWidgetState extends State } break; case AppLifecycleState.inactive: - break; case AppLifecycleState.paused: - controller?.stopImageStream().then((_) => controller?.dispose()); + controller?.dispose(); setState(() { _cameraOn = false; });