rushio-consulting / flutter_camera_ml_vision

A flutter widget that show the camera stream and allow ML vision recognition on it, it allow you to detect barcodes, labels, text, faces...
MIT License
278 stars 107 forks source link

main_live.dart example currentState.toggle() exception #106

Open vasilich6107 opened 4 years ago

vasilich6107 commented 4 years ago

Hi. I'm trying to use toggle from main_live.dart example but getting exception in console.

It seems that the main reason of this exception is that we did not stop streaming before taiking picture.

I tried to add

await _cameraController.stopImageStream().catchError((_) {}); here https://tppr.me/JaUhs and this fixes the issue.

════════ Exception caught by services library ══════════════════════════════════════════════════════
The following PlatformException was thrown while de-activating platform stream on channel plugins.flutter.io/camera/imageStream:
PlatformException(error, Attempt to invoke virtual method 'void android.media.ImageReader.setOnImageAvailableListener(android.media.ImageReader$OnImageAvailableListener, android.os.Handler)' on a null object reference, null)

When the exception was thrown, this was the stack: 
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
<asynchronous suspension>
#2      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:329:12)
#3      EventChannel.receiveBroadcastStream.<anonymous closure> (package:flutter/src/services/platform_channel.dart:531:29)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
vasilich6107 commented 4 years ago

Hi @Kleak @jaumard. Any thoughts, comments?