main, example: added CameraAccessDenied constant

This commit is contained in:
Benjamin Sauer 2018-01-10 14:55:58 +01:00
parent 2156fe33fe
commit 616b286a5c
2 changed files with 2 additions and 1 deletions

View File

@ -48,7 +48,7 @@ class _MyAppState extends State<MyApp> {
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!';
});

View File

@ -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<String> scan() async => await _channel.invokeMethod('scan');