ソースを参照

refactor: safe usage of updateDimensions

flutter-beta
Julian Steenbakker 5年前
コミット
9f7eaec71e
この署名に対応する既知のキーがデータベースに存在しません GPGキーID: 16E437C7A3D94250
1個のファイルの変更4行の追加1行の削除
  1. +4
    -1
      lib/src/qr_code_scanner.dart

+ 4
- 1
lib/src/qr_code_scanner.dart ファイルの表示

@@ -318,11 +318,12 @@ class QRViewController {
} }


/// Updates the view dimensions for iOS. /// Updates the view dimensions for iOS.
static Future<void> updateDimensions(GlobalKey key, MethodChannel channel,
static Future<bool> updateDimensions(GlobalKey key, MethodChannel channel,
{QrScannerOverlayShape? overlay}) async { {QrScannerOverlayShape? overlay}) async {
if (defaultTargetPlatform == TargetPlatform.iOS) { if (defaultTargetPlatform == TargetPlatform.iOS) {
// Add small delay to ensure the render box is loaded // Add small delay to ensure the render box is loaded
await Future.delayed(Duration(milliseconds: 100)); await Future.delayed(Duration(milliseconds: 100));
if (key.currentContext == null) return false;
final renderBox = key.currentContext!.findRenderObject() as RenderBox; final renderBox = key.currentContext!.findRenderObject() as RenderBox;
try { try {
await channel.invokeMethod('setDimensions', { await channel.invokeMethod('setDimensions', {
@@ -331,9 +332,11 @@ class QRViewController {
'scanArea': overlay?.cutOutSize ?? 0, 'scanArea': overlay?.cutOutSize ?? 0,
'scanAreaOffset': overlay?.cutOutBottomOffset ?? 0 'scanAreaOffset': overlay?.cutOutBottomOffset ?? 0
}); });
return true;
} on PlatformException catch (e) { } on PlatformException catch (e) {
throw CameraException(e.code, e.message); throw CameraException(e.code, e.message);
} }
} }
return false;
} }
} }

読み込み中…
キャンセル
保存