From 3ed9d35c5d85f5270adea3582ec10e1167b7db75 Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 5 May 2019 17:14:52 +0200 Subject: [PATCH 1/2] fix crash when poping a route with the camera preview --- CHANGELOG.md | 4 ++++ example/pubspec.lock | 2 +- lib/flutter_camera_ml_vision.dart | 8 ++++++-- pubspec.yaml | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c13601d..9290afa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.0.1] - 5/05/2019 + +* fix a crash when poping a route with the camera preview + ## [2.0.0] - 2/05/2019 * We now forward the result from firebase_ml_vision for onResult diff --git a/example/pubspec.lock b/example/pubspec.lock index 69b3467..25eab6d 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -70,7 +70,7 @@ packages: path: ".." relative: true source: path - version: "2.0.0" + version: "2.0.1" flutter_test: dependency: "direct dev" description: flutter diff --git a/lib/flutter_camera_ml_vision.dart b/lib/flutter_camera_ml_vision.dart index e2eeed7..80cfedf 100644 --- a/lib/flutter_camera_ml_vision.dart +++ b/lib/flutter_camera_ml_vision.dart @@ -91,9 +91,13 @@ class CameraMlVisionState extends State> { } } - Future _stop(bool silently) async { + void _stop(bool silently) { if (_cameraController.value.isStreamingImages) { - await _cameraController.stopImageStream(); + Future.microtask(() async { + if (mounted) { + await _cameraController.stopImageStream(); + } + }); } if (silently) { diff --git a/pubspec.yaml b/pubspec.yaml index a6bae1c..8ef1ee0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_camera_ml_vision description: A flutter widget that show the camera stream and allow ML vision recognition on it, it allow you to detect barcodes, labels, text, faces... -version: 2.0.0 +version: 2.0.1 authors: - Jimmy Aumard - Rushio Consulting From 92ef2b0a2d3c3e56fe8e3dcb451847ce94c98160 Mon Sep 17 00:00:00 2001 From: kevin Date: Sun, 5 May 2019 17:16:27 +0200 Subject: [PATCH 2/2] fix check --- lib/flutter_camera_ml_vision.dart | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/flutter_camera_ml_vision.dart b/lib/flutter_camera_ml_vision.dart index 80cfedf..8026a80 100644 --- a/lib/flutter_camera_ml_vision.dart +++ b/lib/flutter_camera_ml_vision.dart @@ -92,13 +92,11 @@ class CameraMlVisionState extends State> { } void _stop(bool silently) { - if (_cameraController.value.isStreamingImages) { - Future.microtask(() async { - if (mounted) { - await _cameraController.stopImageStream(); - } - }); - } + Future.microtask(() async { + if (_cameraController?.value?.isStreamingImages == true && mounted) { + await _cameraController.stopImageStream(); + } + }); if (silently) { _isStreaming = false;