From 15a197a1241027d8377c4ceee6328e17400dc363 Mon Sep 17 00:00:00 2001 From: M123-dev Date: Fri, 4 Mar 2022 13:30:42 +0100 Subject: [PATCH 1/5] fix: Close barcode scanner and free it's resources --- packages/smooth_app/lib/pages/scan/ml_kit_scan_page.dart | 1 + 1 file changed, 1 insertion(+) 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 da5c74014e0..c03e2880e53 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 @@ -160,6 +160,7 @@ class MLKitScannerPageState extends State { setState(() {}); } await _controller?.dispose(); + barcodeScanner?.close(); _controller?.removeListener(() {}); _controller = null; } From 6d33861ee16bcb4ca4faa697ace2b171d67e0af5 Mon Sep 17 00:00:00 2001 From: M123-dev Date: Fri, 4 Mar 2022 13:40:07 +0100 Subject: [PATCH 2/5] Update ml_kit_scan_page.dart --- packages/smooth_app/lib/pages/scan/ml_kit_scan_page.dart | 2 ++ 1 file changed, 2 insertions(+) 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 c03e2880e53..d25a6163d50 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 @@ -160,6 +160,8 @@ class MLKitScannerPageState extends State { setState(() {}); } await _controller?.dispose(); + // The barcode scanner gets initialized on the first call to process image + // there is no way and need to manually start it. barcodeScanner?.close(); _controller?.removeListener(() {}); _controller = null; From 96319b5c7065887be3d7bdd94033f5b723eb1a83 Mon Sep 17 00:00:00 2001 From: M123-dev Date: Fri, 4 Mar 2022 15:11:39 +0100 Subject: [PATCH 3/5] Upgraded camera --- packages/smooth_app/lib/pages/scan/ml_kit_scan_page.dart | 2 +- packages/smooth_app/pubspec.lock | 2 +- packages/smooth_app/pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 d25a6163d50..600011551b4 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 @@ -160,7 +160,7 @@ class MLKitScannerPageState extends State { setState(() {}); } await _controller?.dispose(); - // The barcode scanner gets initialized on the first call to process image + // The barcode scanner gets initialized on the first call to processImage() // there is no way and need to manually start it. barcodeScanner?.close(); _controller?.removeListener(() {}); diff --git a/packages/smooth_app/pubspec.lock b/packages/smooth_app/pubspec.lock index df758fc078e..a1b3bc8df89 100644 --- a/packages/smooth_app/pubspec.lock +++ b/packages/smooth_app/pubspec.lock @@ -77,7 +77,7 @@ packages: name: camera url: "https://pub.dartlang.org" source: hosted - version: "0.9.4+11" + version: "0.9.4+14" camera_platform_interface: dependency: transitive description: diff --git a/packages/smooth_app/pubspec.yaml b/packages/smooth_app/pubspec.yaml index a508d6a2d47..c0edc8de0dd 100644 --- a/packages/smooth_app/pubspec.yaml +++ b/packages/smooth_app/pubspec.yaml @@ -41,7 +41,7 @@ dependencies: url_launcher: ^6.0.20 visibility_detector: ^0.2.2 google_ml_barcode_scanner: ^0.0.2 - camera: ^0.9.4+11 + camera: ^0.9.4+14 percent_indicator: ^4.0.0 crop_your_image: ^0.6.0+1 mailto: ^2.0.0 From 96a9a0447e73211a8f936930ebf52d0442151862 Mon Sep 17 00:00:00 2001 From: M123-dev Date: Thu, 10 Mar 2022 17:38:37 +0100 Subject: [PATCH 4/5] Update ml_kit_scan_page.dart --- packages/smooth_app/lib/pages/scan/ml_kit_scan_page.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 600011551b4..1428efaa489 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 @@ -118,6 +118,8 @@ class MLKitScannerPageState extends State { return; } + barcodeScanner = GoogleMlKit.vision.barcodeScanner(); + stoppingCamera = false; final CameraDescription camera = cameras[_cameraIndex]; @@ -160,9 +162,8 @@ class MLKitScannerPageState extends State { setState(() {}); } await _controller?.dispose(); - // The barcode scanner gets initialized on the first call to processImage() - // there is no way and need to manually start it. barcodeScanner?.close(); + barcodeScanner = null; _controller?.removeListener(() {}); _controller = null; } From e374d024469704f7d7d3b1d0dd30af203b3e1e7f Mon Sep 17 00:00:00 2001 From: M123-dev Date: Thu, 10 Mar 2022 17:44:39 +0100 Subject: [PATCH 5/5] Update ml_kit_scan_page.dart --- packages/smooth_app/lib/pages/scan/ml_kit_scan_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1428efaa489..69b163374f4 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 @@ -19,7 +19,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; CameraController? _controller;