Skip to content

Commit

Permalink
Added small delay to updateDimensions to ensure that renderbox is loa…
Browse files Browse the repository at this point in the history
…ded. (#250)
  • Loading branch information
juliansteenbakker committed Feb 11, 2021
1 parent 6498932 commit f940d68
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/src/qr_code_scanner.dart
Expand Up @@ -212,7 +212,6 @@ class QRViewController {

Stream<Barcode> get scannedDataStream => _scanUpdateController.stream;

static bool _firstRun = true;
SystemFeatures _features;
bool _hasPermissions;

Expand Down Expand Up @@ -320,10 +319,8 @@ class QRViewController {
static Future<void> 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', {
Expand Down

1 comment on commit f940d68

@vmammanalupo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had run into this issue as well. Glad you fixed it @juliansteenbakker ! I just wanted to ask if you knew if there was a timeline on it being included in a release?

Please sign in to comment.