diff --git a/packages/smooth_app/lib/pages/scan/ml_kit_scan_page.dart b/packages/smooth_app/lib/pages/scan/ml_kit_scan_page.dart index 853f1317af7..514d1b56bdb 100644 --- a/packages/smooth_app/lib/pages/scan/ml_kit_scan_page.dart +++ b/packages/smooth_app/lib/pages/scan/ml_kit_scan_page.dart @@ -22,7 +22,7 @@ class MLKitScannerPage extends StatefulWidget { class MLKitScannerPageState extends State { static const int _SKIPPED_FRAMES = 10; - BarcodeScanner? barcodeScanner = GoogleMlKit.vision.barcodeScanner(); + BarcodeScanner? barcodeScanner; CameraLensDirection cameraLensDirection = CameraLensDirection.back; late ContinuousScanModel _model; late UserPreferences _userPreferences; @@ -123,6 +123,8 @@ class MLKitScannerPageState extends State { return; } + barcodeScanner = GoogleMlKit.vision.barcodeScanner(); + stoppingCamera = false; final CameraDescription camera = cameras[_cameraIndex]; @@ -166,6 +168,8 @@ class MLKitScannerPageState extends State { setState(() {}); } await _controller?.dispose(); + barcodeScanner?.close(); + barcodeScanner = null; _controller?.removeListener(() {}); _controller = null; }