Navaron Bracke

use const for barcode event name

@@ -16,6 +16,10 @@ import 'package:mobile_scanner/src/objects/start_options.dart'; @@ -16,6 +16,10 @@ import 'package:mobile_scanner/src/objects/start_options.dart';
16 16
17 /// An implementation of [MobileScannerPlatform] that uses method channels. 17 /// An implementation of [MobileScannerPlatform] that uses method channels.
18 class MethodChannelMobileScanner extends MobileScannerPlatform { 18 class MethodChannelMobileScanner extends MobileScannerPlatform {
  19 + /// The name of the barcode event that is sent when a barcode is scanned.
  20 + @visibleForTesting
  21 + static const String kBarcodeEventName = 'barcode';
  22 +
19 /// The name of the error event that is sent when a barcode scan error occurs. 23 /// The name of the error event that is sent when a barcode scan error occurs.
20 @visibleForTesting 24 @visibleForTesting
21 static const String kBarcodeErrorEventName = 'MOBILE_SCANNER_BARCODE_ERROR'; 25 static const String kBarcodeErrorEventName = 'MOBILE_SCANNER_BARCODE_ERROR';
@@ -141,7 +145,7 @@ class MethodChannelMobileScanner extends MobileScannerPlatform { @@ -141,7 +145,7 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
141 // Handle incoming barcode events. 145 // Handle incoming barcode events.
142 // The error events are transformed to `MobileScannerBarcodeException` where possible. 146 // The error events are transformed to `MobileScannerBarcodeException` where possible.
143 return eventsStream 147 return eventsStream
144 - .where((e) => e['name'] == 'barcode') 148 + .where((e) => e['name'] == kBarcodeEventName)
145 .map((event) => _parseBarcode(event)) 149 .map((event) => _parseBarcode(event))
146 .handleError(_parseBarcodeError); 150 .handleError(_parseBarcodeError);
147 } 151 }