I'm developing a Flutter project using the mobile_scanner library ^1.0.0 to read a QR code and I found an error when loading it the second time.
It happens me in the Android emulator, I tried it with different Android versions with the same result, you open the QR reader to read one, close it and try to read another one, then the reader just shows a black screen.
I tried to dispose the MobileScanner and some other things without success. I have found some other probably related issues in their Github but in the web and iOs side of Flutter.
The code I created just reproduces one example from its "official docs", a Widget with the Mobile Scanner object to read the QR and a callback to send the read text back.
class QrReadPage extends StatelessWidget {
const QrReadPage({Key? key, required this.qrRead}) : super(key: key);
final void Function(String) qrRead;
@override
Widget build(BuildContext context) {
return MobileScanner(
allowDuplicates: false,
controller: MobileScannerController(),
onDetect: (barcode, args) {
String? code = barcode.rawValue;
qrRead.call(code ?? 'Empty');
});
}
}
This Widget shows when you press a button in the main widget, you can see the full code of the example here.
I would like to know if somebody had to deal with this question before or I just need to create an issue in their Github.