mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
fix null check when user exits out of qr code scanner (#2002)
This commit is contained in:
parent
e88b6b2bcf
commit
1dc7f9309a
5 changed files with 10 additions and 4 deletions
|
@ -12,7 +12,7 @@ import 'package:flutter/scheduler.dart';
|
|||
|
||||
var isQrScannerShown = false;
|
||||
|
||||
Future<String> presentQRScanner(BuildContext context) async {
|
||||
Future<String?> presentQRScanner(BuildContext context) async {
|
||||
isQrScannerShown = true;
|
||||
try {
|
||||
final result = await Navigator.of(context).push<String>(
|
||||
|
@ -23,7 +23,7 @@ Future<String> presentQRScanner(BuildContext context) async {
|
|||
),
|
||||
);
|
||||
isQrScannerShown = false;
|
||||
return result!;
|
||||
return result;
|
||||
} catch (e) {
|
||||
isQrScannerShown = false;
|
||||
rethrow;
|
||||
|
|
|
@ -100,6 +100,7 @@ class AnimatedURPage extends BasePage {
|
|||
switch (urQrType) {
|
||||
case "ur:xmr-txunsigned": // ur:xmr-txsigned
|
||||
final ur = await presentQRScanner(context);
|
||||
if (ur == null) return;
|
||||
final result = await monero!.commitTransactionUR(animatedURmodel.wallet, ur);
|
||||
if (result) {
|
||||
Navigator.of(context).pop(true);
|
||||
|
@ -107,6 +108,7 @@ class AnimatedURPage extends BasePage {
|
|||
break;
|
||||
case "ur:xmr-output": // xmr-keyimage
|
||||
final ur = await presentQRScanner(context);
|
||||
if (ur == null) return;
|
||||
final result = await monero!.importKeyImagesUR(animatedURmodel.wallet, ur);
|
||||
if (result) {
|
||||
Navigator.of(context).pop(true);
|
||||
|
|
|
@ -233,6 +233,7 @@ class AddressTextField<T extends Currency> extends StatelessWidget{
|
|||
await PermissionHandler.checkPermission(Permission.camera, context);
|
||||
if (!isCameraPermissionGranted) return;
|
||||
final code = await presentQRScanner(context);
|
||||
if (code == null) return;
|
||||
if (code.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -215,7 +215,9 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
|||
bool isCameraPermissionGranted =
|
||||
await PermissionHandler.checkPermission(Permission.camera, context);
|
||||
if (!isCameraPermissionGranted) return;
|
||||
String code = await presentQRScanner(context);
|
||||
String? code = await presentQRScanner(context);
|
||||
if (code == null) throw Exception("Unexpected QR code value: aborted");
|
||||
|
||||
if (code.isEmpty) {
|
||||
throw Exception('Unexpected scan QR code value: value is empty');
|
||||
}
|
||||
|
|
|
@ -89,7 +89,8 @@ class WalletRestoreFromQRCode {
|
|||
}
|
||||
|
||||
static Future<RestoredWallet> scanQRCodeForRestoring(BuildContext context) async {
|
||||
String code = await presentQRScanner(context);
|
||||
String? code = await presentQRScanner(context);
|
||||
if (code == null) throw Exception("Unexpected scan QR code value: aborted");
|
||||
if (code.isEmpty) throw Exception('Unexpected scan QR code value: value is empty');
|
||||
|
||||
WalletType? walletType;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue