From f940d6811b5f7acadf471b35055b987d1734510c Mon Sep 17 00:00:00 2001 From: Julian Steenbakker Date: Thu, 11 Feb 2021 16:09:20 +0100 Subject: [PATCH] Added small delay to updateDimensions to ensure that renderbox is loaded. (#250) --- lib/src/qr_code_scanner.dart | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/src/qr_code_scanner.dart b/lib/src/qr_code_scanner.dart index 2e7b9ee..22a62dc 100644 --- a/lib/src/qr_code_scanner.dart +++ b/lib/src/qr_code_scanner.dart @@ -212,7 +212,6 @@ class QRViewController { Stream get scannedDataStream => _scanUpdateController.stream; - static bool _firstRun = true; SystemFeatures _features; bool _hasPermissions; @@ -320,10 +319,8 @@ class QRViewController { static Future updateDimensions(GlobalKey key, MethodChannel channel, {QrScannerOverlayShape overlay}) async { if (defaultTargetPlatform == TargetPlatform.iOS) { - if (_firstRun) { - _firstRun = false; - await Future.delayed(Duration(milliseconds: 300)); - } + // Add small delay to ensure the renderbox is loaded + await Future.delayed(Duration(milliseconds: 100)); final RenderBox renderBox = key.currentContext.findRenderObject(); try { await channel.invokeMethod('setDimensions', {