Navaron Bracke

format

@@ -6,7 +6,8 @@ import 'package:mobile_scanner_example/scanner_error_widget.dart'; @@ -6,7 +6,8 @@ import 'package:mobile_scanner_example/scanner_error_widget.dart';
6 6
7 class BarcodeScannerWithOverlay extends StatefulWidget { 7 class BarcodeScannerWithOverlay extends StatefulWidget {
8 @override 8 @override
9 - _BarcodeScannerWithOverlayState createState() => _BarcodeScannerWithOverlayState(); 9 + _BarcodeScannerWithOverlayState createState() =>
  10 + _BarcodeScannerWithOverlayState();
10 } 11 }
11 12
12 class _BarcodeScannerWithOverlayState extends State<BarcodeScannerWithOverlay> { 13 class _BarcodeScannerWithOverlayState extends State<BarcodeScannerWithOverlay> {
@@ -58,7 +59,9 @@ class _BarcodeScannerWithOverlayState extends State<BarcodeScannerWithOverlay> { @@ -58,7 +59,9 @@ class _BarcodeScannerWithOverlayState extends State<BarcodeScannerWithOverlay> {
58 ValueListenableBuilder( 59 ValueListenableBuilder(
59 valueListenable: controller, 60 valueListenable: controller,
60 builder: (context, value, child) { 61 builder: (context, value, child) {
61 - if (!value.isInitialized || !value.isRunning || value.error != null) { 62 + if (!value.isInitialized ||
  63 + !value.isRunning ||
  64 + value.error != null) {
62 return const SizedBox(); 65 return const SizedBox();
63 } 66 }
64 67
@@ -151,6 +154,7 @@ class ScannerOverlay extends CustomPainter { @@ -151,6 +154,7 @@ class ScannerOverlay extends CustomPainter {
151 154
152 @override 155 @override
153 bool shouldRepaint(ScannerOverlay oldDelegate) { 156 bool shouldRepaint(ScannerOverlay oldDelegate) {
154 - return scanWindow != oldDelegate.scanWindow || borderRadius != oldDelegate.borderRadius; 157 + return scanWindow != oldDelegate.scanWindow ||
  158 + borderRadius != oldDelegate.borderRadius;
155 } 159 }
156 } 160 }
@@ -101,12 +101,14 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -101,12 +101,14 @@ class MobileScannerWeb extends MobileScannerPlatform {
101 throw const MobileScannerException( 101 throw const MobileScannerException(
102 errorCode: MobileScannerErrorCode.unsupported, 102 errorCode: MobileScannerErrorCode.unsupported,
103 errorDetails: MobileScannerErrorDetails( 103 errorDetails: MobileScannerErrorDetails(
104 - message: 'This browser does not support displaying video from the camera.', 104 + message:
  105 + 'This browser does not support displaying video from the camera.',
105 ), 106 ),
106 ); 107 );
107 } 108 }
108 109
109 - final MediaTrackSupportedConstraints capabilities = window.navigator.mediaDevices.getSupportedConstraints(); 110 + final MediaTrackSupportedConstraints capabilities =
  111 + window.navigator.mediaDevices.getSupportedConstraints();
110 112
111 final MediaStreamConstraints constraints; 113 final MediaStreamConstraints constraints;
112 114
@@ -128,8 +130,9 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -128,8 +130,9 @@ class MobileScannerWeb extends MobileScannerPlatform {
128 // If the completer is not null, the permission was never requested before. 130 // If the completer is not null, the permission was never requested before.
129 _cameraPermissionCompleter ??= Completer<void>(); 131 _cameraPermissionCompleter ??= Completer<void>();
130 132
131 - final MediaStream? videoStream =  
132 - await window.navigator.mediaDevices.getUserMedia(constraints).toDart as MediaStream?; 133 + final MediaStream? videoStream = await window.navigator.mediaDevices
  134 + .getUserMedia(constraints)
  135 + .toDart as MediaStream?;
133 136
134 // At this point the permission is granted. 137 // At this point the permission is granted.
135 if (!_cameraPermissionCompleter!.isCompleted) { 138 if (!_cameraPermissionCompleter!.isCompleted) {
@@ -140,7 +143,8 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -140,7 +143,8 @@ class MobileScannerWeb extends MobileScannerPlatform {
140 throw const MobileScannerException( 143 throw const MobileScannerException(
141 errorCode: MobileScannerErrorCode.genericError, 144 errorCode: MobileScannerErrorCode.genericError,
142 errorDetails: MobileScannerErrorDetails( 145 errorDetails: MobileScannerErrorDetails(
143 - message: 'Could not create a video stream from the camera with the given options. ' 146 + message:
  147 + 'Could not create a video stream from the camera with the given options. '
144 'The browser might not support the given constraints.', 148 'The browser might not support the given constraints.',
145 ), 149 ),
146 ); 150 );
@@ -159,7 +163,8 @@ class MobileScannerWeb extends MobileScannerPlatform { @@ -159,7 +163,8 @@ class MobileScannerWeb extends MobileScannerPlatform {
159 MobileScannerErrorCode errorCode = MobileScannerErrorCode.genericError; 163 MobileScannerErrorCode errorCode = MobileScannerErrorCode.genericError;
160 164
161 // Handle both unsupported and permission errors from the web. 165 // Handle both unsupported and permission errors from the web.
162 - if (errorMessage.contains('NotFoundError') || errorMessage.contains('NotSupportedError')) { 166 + if (errorMessage.contains('NotFoundError') ||
  167 + errorMessage.contains('NotSupportedError')) {
163 errorCode = MobileScannerErrorCode.unsupported; 168 errorCode = MobileScannerErrorCode.unsupported;
164 } else if (errorMessage.contains('NotAllowedError')) { 169 } else if (errorMessage.contains('NotAllowedError')) {
165 errorCode = MobileScannerErrorCode.permissionDenied; 170 errorCode = MobileScannerErrorCode.permissionDenied;