Navaron Bracke

use error builder in example

import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:mobile_scanner_example/scanner_error_widget.dart';
class BarcodeListScannerWithController extends StatefulWidget {
const BarcodeListScannerWithController({Key? key}) : super(key: key);
... ... @@ -25,7 +26,6 @@ class _BarcodeListScannerWithControllerState
);
bool isStarted = true;
MobileScannerException? exception;
void _startOrStop() {
if (isStarted) {
... ... @@ -33,9 +33,7 @@ class _BarcodeListScannerWithControllerState
} else {
controller.start().catchError((error) {
if (mounted) {
setState(() {
exception = error as MobileScannerException;
});
setState(() {});
}
});
}
... ... @@ -55,6 +53,9 @@ class _BarcodeListScannerWithControllerState
children: [
MobileScanner(
controller: controller,
errorBuilder: (context, error, child) {
return ScannerErrorWidget(error: error);
},
fit: BoxFit.contain,
onDetect: (barcodeCapture) {
setState(() {
... ...
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:mobile_scanner_example/scanner_error_widget.dart';
class BarcodeScannerWithController extends StatefulWidget {
const BarcodeScannerWithController({Key? key}) : super(key: key);
... ... @@ -25,7 +26,6 @@ class _BarcodeScannerWithControllerState
);
bool isStarted = true;
MobileScannerException? exception;
void _startOrStop() {
if (isStarted) {
... ... @@ -33,9 +33,7 @@ class _BarcodeScannerWithControllerState
} else {
controller.start().catchError((error) {
if (mounted) {
setState(() {
exception = error as MobileScannerException;
});
setState(() {});
}
});
}
... ... @@ -55,6 +53,9 @@ class _BarcodeScannerWithControllerState
children: [
MobileScanner(
controller: controller,
errorBuilder: (context, error, child) {
return ScannerErrorWidget(error: error);
},
fit: BoxFit.contain,
onDetect: (barcode) {
setState(() {
... ...
... ... @@ -2,6 +2,7 @@ import 'dart:math';
import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:mobile_scanner_example/scanner_error_widget.dart';
class BarcodeScannerReturningImage extends StatefulWidget {
const BarcodeScannerReturningImage({Key? key}) : super(key: key);
... ... @@ -27,7 +28,6 @@ class _BarcodeScannerReturningImageState
);
bool isStarted = true;
MobileScannerException? exception;
void _startOrStop() {
if (isStarted) {
... ... @@ -35,9 +35,7 @@ class _BarcodeScannerReturningImageState
} else {
controller.start().catchError((error) {
if (mounted) {
setState(() {
exception = error as MobileScannerException;
});
setState(() {});
}
});
}
... ... @@ -77,6 +75,9 @@ class _BarcodeScannerReturningImageState
children: [
MobileScanner(
controller: controller,
errorBuilder: (context, error, child) {
return ScannerErrorWidget(error: error);
},
fit: BoxFit.contain,
onDetect: (barcode) {
setState(() {
... ...
import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:mobile_scanner_example/scanner_error_widget.dart';
class BarcodeScannerWithoutController extends StatefulWidget {
const BarcodeScannerWithoutController({Key? key}) : super(key: key);
... ... @@ -24,6 +25,9 @@ class _BarcodeScannerWithoutControllerState
children: [
MobileScanner(
fit: BoxFit.contain,
errorBuilder: (context, error, child) {
return ScannerErrorWidget(error: error);
},
onDetect: (capture) {
setState(() {
this.capture = capture;
... ...