From 73c7a7ea3b6d00d84212d9d85c2335536a0d7628 Mon Sep 17 00:00:00 2001 From: "brandon.maness" Date: Mon, 22 Jul 2019 12:11:27 -0500 Subject: [PATCH] Fix dart future not returning on cancel --- ios/Classes/BarcodeScanPlugin.h | 2 +- ios/Classes/BarcodeScannerViewController.m | 1 + lib/barcode_scan.dart | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ios/Classes/BarcodeScanPlugin.h b/ios/Classes/BarcodeScanPlugin.h index 197399e..d6b1bab 100644 --- a/ios/Classes/BarcodeScanPlugin.h +++ b/ios/Classes/BarcodeScanPlugin.h @@ -9,6 +9,6 @@ @interface BarcodeScanPlugin : NSObject -@property(nonatomic, retain) FlutterResult result; +@property(nonatomic, copy) FlutterResult result; @property (nonatomic, assign) UIViewController *hostViewController; @end diff --git a/ios/Classes/BarcodeScannerViewController.m b/ios/Classes/BarcodeScannerViewController.m index 52e07de..da44ca0 100644 --- a/ios/Classes/BarcodeScannerViewController.m +++ b/ios/Classes/BarcodeScannerViewController.m @@ -82,6 +82,7 @@ } - (void)cancel { + [self.delegate barcodeScannerViewController:self didFailWithErrorCode:@"USER_CANCELED"]; [self dismissViewControllerAnimated:true completion:nil]; } diff --git a/lib/barcode_scan.dart b/lib/barcode_scan.dart index d042a3d..048be77 100644 --- a/lib/barcode_scan.dart +++ b/lib/barcode_scan.dart @@ -4,6 +4,7 @@ import 'package:flutter/services.dart'; class BarcodeScanner { static const CameraAccessDenied = 'PERMISSION_NOT_GRANTED'; + static const UserCanceled = 'USER_CANCELED'; static const MethodChannel _channel = const MethodChannel('com.apptreesoftware.barcode_scan'); static Future scan() async => await _channel.invokeMethod('scan');