From 6d8b7799f9399e5b78aeb426531fc1300137eaa4 Mon Sep 17 00:00:00 2001 From: Julian Steenbakker Date: Tue, 15 Dec 2020 09:54:58 +0100 Subject: [PATCH] Updated Flutter min sdk of example to match plugin. Updated README.md --- example/README.md | 38 ++++++++++++++++++++++++-------------- example/lib/main.dart | 2 +- example/pubspec.yaml | 2 +- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/example/README.md b/example/README.md index d9a96cd..4fc9d62 100644 --- a/example/README.md +++ b/example/README.md @@ -52,20 +52,7 @@ class _QRViewExampleState extends State { return Scaffold( body: Column( children: [ - Expanded( - flex: 4, - child: QRView( - key: qrKey, - onQRViewCreated: _onQRViewCreated, - overlay: QrScannerOverlayShape( - borderColor: Colors.red, - borderRadius: 10, - borderLength: 30, - borderWidth: 10, - cutOutSize: 300, - ), - ), - ), + Expanded(flex: 4, child: _buildQrView(context)), Expanded( flex: 1, child: FittedBox( @@ -163,6 +150,29 @@ class _QRViewExampleState extends State { return backCamera == current; } + Widget _buildQrView(BuildContext context) { + // To ensure the Scanner view is properly sizes after rotation + // we need to listen for Flutter SizeChanged notification and update controller + return NotificationListener( + 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) { diff --git a/example/lib/main.dart b/example/lib/main.dart index 8d957bd..4facbeb 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -129,7 +129,7 @@ class _QRViewExampleState extends State { 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 + // we need to listen for Flutter SizeChanged notification and update controller return NotificationListener( onNotification: (notification) { Future.microtask(() => controller?.updateDimensions(qrKey)); diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 02dae87..6df5ea4 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -3,7 +3,7 @@ description: Demonstrates how to use the flutter_qr plugin. publish_to: 'none' environment: - sdk: ">=2.0.0-dev.68.0 <3.0.0" + sdk: ">=2.3.0 <3.0.0" dependencies: flutter: