Add onError function #464
Replies: 2 comments 1 reply
-
I'm not sure about the implementation of this, I haven't read enough of the package but this seems like a great idea. I can't currently find a way to catch 'No camera found or failed to open camera!' when on a device without a camera in this package. I am having to import another package to check if a camera is available before using MobileScanner. It would be nice if there was a check if a camera is available in this package or a way to handle errors thrown by the mobile scanner. If there is already a way that I have missed then my bad! Example of what I would like to be able to do: if (MobileScanner.cameraIsAailable() .... show my mobile scanner Or alternatively MobileScanner( |
Beta Was this translation helpful? Give feedback.
-
I just released v3.0.0 which has an onError widget. Please see the example app for more information. |
Beta Was this translation helpful? Give feedback.
-
Hello.
I have tried your package but there is no return error function.
I have investigate the code and i have the idea to add onError function call.
/-----------------------------------------------------------------/
In MobileScanner class
StreamSubscription<MobileScannerException>? _errorcodesSubscription;
in _MobileScannerState class. That will be listen in initstate() :
_errorcodesSubscription = _controller.errorcode.listen( widget.onError, );
and add "onError" in the MobileScanner required param.
/-----------------------------------------------------------------/
In MobileScannerController class add this :
final StreamController<MobileScannerException> _errorController =
StreamController.broadcast();
Stream<MobileScannerException> get errorcode => _errorController.stream;
In the function Future<MobileScannerArguments?> start, add in switch case the add stream value of the
MobileScannerErrorCode like this :
_errorController.add( const MobileScannerException( errorCode: MobileScannerErrorCode.genericError ) );
/-----------------------------------------------------------------/
Hope that you can understand. If need, i can give files of changed class.
Thank you,
Regards
Beta Was this translation helpful? Give feedback.
All reactions