Browse Source

main, example: added CameraAccessDenied constant

master
Benjamin Sauer 4 years ago
parent
commit
616b286a5c
  1. 2
      example/lib/main.dart
  2. 1
      lib/barcode_scan.dart

2
example/lib/main.dart

@ -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!';
});

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

Loading…
Cancel
Save