From 9cfc124f9feab305d59123f9eff996c71821e932 Mon Sep 17 00:00:00 2001 From: Julian Steenbakker Date: Mon, 21 Dec 2020 22:39:39 +0100 Subject: [PATCH] Updated README.md --- README.md | 10 +++++++--- example/README.md | 24 ++++++++++++++++++------ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 973c25c..3a95069 100644 --- a/README.md +++ b/README.md @@ -56,12 +56,16 @@ class _QRViewExampleState extends State { Barcode result; QRViewController controller; - /// Overriding reassemble and pausing the camera - /// ensures us that hot reload won't give a black screen + // In order to get hot reload to work we need to pause the camera if the platform + // is android, or resume the camera if the platform is iOS. @override void reassemble() { super.reassemble(); - controller.pauseCamera(); + if (Platform.isAndroid) { + controller.pauseCamera(); + } else if (Platform.isIOS) { + controller.resumeCamera(); + } } @override diff --git a/example/README.md b/example/README.md index 866b9a4..20d5579 100644 --- a/example/README.md +++ b/example/README.md @@ -47,12 +47,16 @@ class _QRViewExampleState extends State { QRViewController controller; final GlobalKey qrKey = GlobalKey(debugLabel: 'QR'); - /// Overriding reassemble and pausing the camera - /// ensures us that hot reload won't give a black screen + // In order to get hot reload to work we need to pause the camera if the platform + // is android, or resume the camera if the platform is iOS. @override void reassemble() { super.reassemble(); - controller.pauseCamera(); + if (Platform.isAndroid) { + controller.pauseCamera(); + } else if (Platform.isIOS) { + controller.resumeCamera(); + } } @override @@ -69,7 +73,8 @@ class _QRViewExampleState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ if (result != null) - Text('Barcode Type: ${describeEnum(result.format)} Data: ${result.code}') + Text( + 'Barcode Type: ${describeEnum(result.format)} Data: ${result.code}') else Text('Scan a code'), Row( @@ -162,11 +167,17 @@ class _QRViewExampleState extends State { } Widget _buildQrView(BuildContext context) { + // For this example we check how width or tall the device is and change the scanArea and overlay accordingly. + var scanArea = (MediaQuery.of(context).size.width < 400 || + MediaQuery.of(context).size.height < 400) + ? 150.0 + : 300.0; // 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)); + Future.microtask( + () => controller?.updateDimensions(qrKey, scanArea: scanArea)); return false; }, child: SizeChangedLayoutNotifier( @@ -179,7 +190,7 @@ class _QRViewExampleState extends State { borderRadius: 10, borderLength: 30, borderWidth: 10, - cutOutSize: 300, + cutOutSize: scanArea, ), ))); } @@ -201,6 +212,7 @@ class _QRViewExampleState extends State { } + ```