mobile_scanner
mobile_scanner copied to clipboard
A black screen on IOS 15.4.1
When I first entered the page on IOS 15.4.1, it gave me a black screen. I need to switch to the background and come back for it to work. But it is ok on Android. Please hepl me,what can i do?Thank you!
up
same issue on web
I found a solution that works for me
just play camera in initstate and stop it in dispose by controller:
MobileScannerController? cameraController;
@override
void initState() {
super.initState();
cameraController = MobileScannerController();
cameraController!.start()
}
@override
void dispose() {
cameraController?.stop();
cameraController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MobileScanner(
controller: cameraController,
fit: BoxFit.cover,
onDetect: (barcode, args) {
setState(() {
this.barcode = barcode.rawValue;
});
},
);
}
up
same issue on web
I found a solution that works for me
just play camera in initstate and stop it in dispose by controller:
MobileScannerController? cameraController; @override void initState() { super.initState(); cameraController = MobileScannerController(); cameraController!.start() } @override void dispose() { cameraController?.stop(); cameraController?.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return MobileScanner( controller: cameraController, fit: BoxFit.cover, onDetect: (barcode, args) { setState(() { this.barcode = barcode.rawValue; }); }, ); }
Didn't work for me on Web. Android doesn't have this problem
I tried using the example app on my iPad running iOS 15.5, but i don't have any problems. Do you maybe have any code to reproduce this issue?
Same issue on IOS 15.5
Showing black screen while open second time scanner.
Same issue here.
Flutter 2.8.1 Dart 2.15.1
Create a MobileScanner(onDetect: (p0, p1) {})
Error: MobileScanner: Called start() while already started!
Black screen of death. Sometimes I can get it to pop up if I try navigator.pop, but it's not 100%.
Removing start from MobileScannerController resolves the issue for us
MobileScannerController({
this.facing = CameraFacing.back,
this.ratio,
this.torchEnabled,
this.formats,
}) {
// In case a new instance is created before calling dispose()
if (_controllerHashcode != null) {
stop();
}
_controllerHashcode = hashCode;
cameraFacingState = ValueNotifier(facing);
// Sets analyze mode and barcode stream
barcodesController = StreamController.broadcast(
// onListen: () => setAnalyzeMode(AnalyzeMode.barcode.index),
// onCancel: () => setAnalyzeMode(AnalyzeMode.none.index),
);
// start(); //! <- removed
// Listen to events from the platform specific code
events = eventChannel
.receiveBroadcastStream()
.listen((data) => handleEvent(data as Map));
}
Edit: This was only tested on iOS 15.5 and android 10!
I've tried all of the solutions posted, nothing works. What I did and immediately worked is, onReady()
just stop the camera controller.
Notice that I am using GetX.
Here my code (and fixes all of these issues), though I still get a warning Called stop() while already stopped!
, but it works.
@override
void onReady() {
scanController.stop();
super.onReady();
}
I have the same issue on iOS
I am also getting the same issue on iOS 15.3.1 with Flutter 3
Same Issue !!
Since there has been lots of updates, please check with latest version 3.0.0-beta.4 and comment if this issue still exists.