Julian Steenbakker
Committed by GitHub

Merge pull request #104 from brandsimon/sbr/readme_nullable

Enhance documentation: barcode.rawValue can be null
Showing 1 changed file with 18 additions and 6 deletions
... ... @@ -71,8 +71,12 @@ import 'package:mobile_scanner/mobile_scanner.dart';
body: MobileScanner(
allowDuplicates: false,
onDetect: (barcode, args) {
final String code = barcode.rawValue;
debugPrint('Barcode found! $code');
if (barcode.rawValue == null) {
debugPrint('Failed to scan Barcode');
} else {
final String code = barcode.rawValue!;
debugPrint('Barcode found! $code');
}
}),
);
}
... ... @@ -92,8 +96,12 @@ import 'package:mobile_scanner/mobile_scanner.dart';
controller: MobileScannerController(
facing: CameraFacing.front, torchEnabled: true),
onDetect: (barcode, args) {
final String code = barcode.rawValue;
debugPrint('Barcode found! $code');
if (barcode.rawValue == null) {
debugPrint('Failed to scan Barcode');
} else {
final String code = barcode.rawValue!;
debugPrint('Barcode found! $code');
}
}),
);
}
... ... @@ -150,8 +158,12 @@ import 'package:mobile_scanner/mobile_scanner.dart';
allowDuplicates: false,
controller: cameraController,
onDetect: (barcode, args) {
final String code = barcode.rawValue;
debugPrint('Barcode found! $code');
if (barcode.rawValue == null) {
debugPrint('Failed to scan Barcode');
} else {
final String code = barcode.rawValue!;
debugPrint('Barcode found! $code');
}
}));
}
```
... ...