Merge pull request #134 from brandon8863/master

Fix dart future not returning on cancel
This commit is contained in:
Matthew Smith 2019-07-30 11:26:44 -07:00 committed by GitHub
commit 39ecc57bc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 1 deletions

View File

@ -9,6 +9,6 @@
@interface BarcodeScanPlugin : NSObject<FlutterPlugin, BarcodeScannerViewControllerDelegate> @interface BarcodeScanPlugin : NSObject<FlutterPlugin, BarcodeScannerViewControllerDelegate>
@property(nonatomic, retain) FlutterResult result; @property(nonatomic, copy) FlutterResult result;
@property (nonatomic, assign) UIViewController *hostViewController; @property (nonatomic, assign) UIViewController *hostViewController;
@end @end

View File

@ -82,6 +82,7 @@
} }
- (void)cancel { - (void)cancel {
[self.delegate barcodeScannerViewController:self didFailWithErrorCode:@"USER_CANCELED"];
[self dismissViewControllerAnimated:true completion:nil]; [self dismissViewControllerAnimated:true completion:nil];
} }

View File

@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
class BarcodeScanner { class BarcodeScanner {
static const CameraAccessDenied = 'PERMISSION_NOT_GRANTED'; static const CameraAccessDenied = 'PERMISSION_NOT_GRANTED';
static const UserCanceled = 'USER_CANCELED';
static const MethodChannel _channel = static const MethodChannel _channel =
const MethodChannel('com.apptreesoftware.barcode_scan'); const MethodChannel('com.apptreesoftware.barcode_scan');
static Future<String> scan() async => await _channel.invokeMethod('scan'); static Future<String> scan() async => await _channel.invokeMethod('scan');