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;
|
var isQrScannerShown = false;
|
||||||
|
|
||||||
Future<String> presentQRScanner(BuildContext context) async {
|
Future<String?> presentQRScanner(BuildContext context) async {
|
||||||
isQrScannerShown = true;
|
isQrScannerShown = true;
|
||||||
try {
|
try {
|
||||||
final result = await Navigator.of(context).push<String>(
|
final result = await Navigator.of(context).push<String>(
|
||||||
|
@ -23,7 +23,7 @@ Future<String> presentQRScanner(BuildContext context) async {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
isQrScannerShown = false;
|
isQrScannerShown = false;
|
||||||
return result!;
|
return result;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
isQrScannerShown = false;
|
isQrScannerShown = false;
|
||||||
rethrow;
|
rethrow;
|
||||||
|
|
|
@ -100,6 +100,7 @@ class AnimatedURPage extends BasePage {
|
||||||
switch (urQrType) {
|
switch (urQrType) {
|
||||||
case "ur:xmr-txunsigned": // ur:xmr-txsigned
|
case "ur:xmr-txunsigned": // ur:xmr-txsigned
|
||||||
final ur = await presentQRScanner(context);
|
final ur = await presentQRScanner(context);
|
||||||
|
if (ur == null) return;
|
||||||
final result = await monero!.commitTransactionUR(animatedURmodel.wallet, ur);
|
final result = await monero!.commitTransactionUR(animatedURmodel.wallet, ur);
|
||||||
if (result) {
|
if (result) {
|
||||||
Navigator.of(context).pop(true);
|
Navigator.of(context).pop(true);
|
||||||
|
@ -107,6 +108,7 @@ class AnimatedURPage extends BasePage {
|
||||||
break;
|
break;
|
||||||
case "ur:xmr-output": // xmr-keyimage
|
case "ur:xmr-output": // xmr-keyimage
|
||||||
final ur = await presentQRScanner(context);
|
final ur = await presentQRScanner(context);
|
||||||
|
if (ur == null) return;
|
||||||
final result = await monero!.importKeyImagesUR(animatedURmodel.wallet, ur);
|
final result = await monero!.importKeyImagesUR(animatedURmodel.wallet, ur);
|
||||||
if (result) {
|
if (result) {
|
||||||
Navigator.of(context).pop(true);
|
Navigator.of(context).pop(true);
|
||||||
|
|
|
@ -233,6 +233,7 @@ class AddressTextField<T extends Currency> extends StatelessWidget{
|
||||||
await PermissionHandler.checkPermission(Permission.camera, context);
|
await PermissionHandler.checkPermission(Permission.camera, context);
|
||||||
if (!isCameraPermissionGranted) return;
|
if (!isCameraPermissionGranted) return;
|
||||||
final code = await presentQRScanner(context);
|
final code = await presentQRScanner(context);
|
||||||
|
if (code == null) return;
|
||||||
if (code.isEmpty) {
|
if (code.isEmpty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,9 @@ abstract class NodeCreateOrEditViewModelBase with Store {
|
||||||
bool isCameraPermissionGranted =
|
bool isCameraPermissionGranted =
|
||||||
await PermissionHandler.checkPermission(Permission.camera, context);
|
await PermissionHandler.checkPermission(Permission.camera, context);
|
||||||
if (!isCameraPermissionGranted) return;
|
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) {
|
if (code.isEmpty) {
|
||||||
throw Exception('Unexpected scan QR code value: value is empty');
|
throw Exception('Unexpected scan QR code value: value is empty');
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,8 @@ class WalletRestoreFromQRCode {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<RestoredWallet> scanQRCodeForRestoring(BuildContext context) async {
|
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');
|
if (code.isEmpty) throw Exception('Unexpected scan QR code value: value is empty');
|
||||||
|
|
||||||
WalletType? walletType;
|
WalletType? walletType;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue