I'm using QRView but the camera doesn't open until I tap/click the container. I want the camera to open while the page is rendered. How can i fix that?
Here is my code:
Container(
height: ScreenSize.getScreenWidth(context) / 1.6,
width: ScreenSize.getScreenWidth(context) / 1.6,
color: Colors.pink,
child: QRView(
key: qrKey,
onQRViewCreated: _onQRViewCreated,
),
),
Here is _onQRViewCreated function:
void _onQRViewCreated(QRViewController controller) {
this.controller = controller;
controller.scannedDataStream.listen((scanData) {
setState(() {
result = scanData;
});
});
}
CodePudding user response:
If you are using qr_code_scanner while using Flutter 3, it may not work well on android. It happened to me too. Finally I used mobile_scanner instead of qr_code_scanner.
CodePudding user response:
I found it just add this line
controller.resumeCamera();
Function is:
void _onQRViewCreated(QRViewController controller) {
this.controller = controller;
controller.resumeCamera();
controller.scannedDataStream.listen((scanData) {
setState(() {
result = scanData;
});
});
}