From 616b286a5c0a049dc23abc7183a9a3190e9c19f3 Mon Sep 17 00:00:00 2001 From: Benjamin Sauer Date: Wed, 10 Jan 2018 14:55:58 +0100 Subject: [PATCH] main, example: added CameraAccessDenied constant --- example/lib/main.dart | 2 +- lib/barcode_scan.dart | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index d91f89b..34a643d 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -48,7 +48,7 @@ class _MyAppState extends State { String barcode = await BarcodeScanner.scan(); setState(() => this.barcode = barcode); } on PlatformException catch (e) { - if (e.code == 'PERMISSION_NOT_GRANTED') { + if (e.code == BarcodeScanner.CameraAccessDenied) { setState(() { this.barcode = 'The user did not grant the camera permission!'; }); diff --git a/lib/barcode_scan.dart b/lib/barcode_scan.dart index f375363..d042a3d 100644 --- a/lib/barcode_scan.dart +++ b/lib/barcode_scan.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:flutter/services.dart'; class BarcodeScanner { + static const CameraAccessDenied = 'PERMISSION_NOT_GRANTED'; static const MethodChannel _channel = const MethodChannel('com.apptreesoftware.barcode_scan'); static Future scan() async => await _channel.invokeMethod('scan');