|
|
|
@@ -29,21 +29,7 @@ class _QRViewExampleState extends State<QRViewExample> { |
|
|
|
return Scaffold( |
|
|
|
body: Column( |
|
|
|
children: <Widget>[ |
|
|
|
Expanded( |
|
|
|
flex: 4, |
|
|
|
child: QRView( |
|
|
|
key: qrKey, |
|
|
|
onQRViewCreated: _onQRViewCreated, |
|
|
|
overlay: QrScannerOverlayShape( |
|
|
|
borderColor: Colors.red, |
|
|
|
borderRadius: 10, |
|
|
|
borderLength: 30, |
|
|
|
borderWidth: 10, |
|
|
|
cutOutSize: 300, |
|
|
|
cutOutBottomOffset: 24, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Expanded(flex: 4, child: _buildQrView(context)), |
|
|
|
Expanded( |
|
|
|
flex: 1, |
|
|
|
child: FittedBox( |
|
|
|
@@ -141,6 +127,29 @@ class _QRViewExampleState extends State<QRViewExample> { |
|
|
|
return backCamera == current; |
|
|
|
} |
|
|
|
|
|
|
|
Widget _buildQrView(BuildContext context) { |
|
|
|
// To ensure the Scanner view is properly sizes after rotation |
|
|
|
// we need to listen for Flutter SizeChanged notifiation and update controller |
|
|
|
return NotificationListener<SizeChangedLayoutNotification>( |
|
|
|
onNotification: (notification) { |
|
|
|
Future.microtask(() => controller?.updateDimensions(qrKey)); |
|
|
|
return false; |
|
|
|
}, |
|
|
|
child: SizeChangedLayoutNotifier( |
|
|
|
key: const Key('qr-size-notifier'), |
|
|
|
child: QRView( |
|
|
|
key: qrKey, |
|
|
|
onQRViewCreated: _onQRViewCreated, |
|
|
|
overlay: QrScannerOverlayShape( |
|
|
|
borderColor: Colors.red, |
|
|
|
borderRadius: 10, |
|
|
|
borderLength: 30, |
|
|
|
borderWidth: 10, |
|
|
|
cutOutSize: 300, |
|
|
|
), |
|
|
|
))); |
|
|
|
} |
|
|
|
|
|
|
|
void _onQRViewCreated(QRViewController controller) { |
|
|
|
this.controller = controller; |
|
|
|
controller.scannedDataStream.listen((scanData) { |
|
|
|
|