Julian Steenbakker

style: flutter format

@@ -13,7 +13,6 @@ class BarcodeListScannerWithController extends StatefulWidget { @@ -13,7 +13,6 @@ class BarcodeListScannerWithController extends StatefulWidget {
13 class _BarcodeListScannerWithControllerState 13 class _BarcodeListScannerWithControllerState
14 extends State<BarcodeListScannerWithController> 14 extends State<BarcodeListScannerWithController>
15 with SingleTickerProviderStateMixin { 15 with SingleTickerProviderStateMixin {
16 -  
17 BarcodeCapture? barcodeCapture; 16 BarcodeCapture? barcodeCapture;
18 17
19 MobileScannerController controller = MobileScannerController( 18 MobileScannerController controller = MobileScannerController(
@@ -170,4 +169,4 @@ class _BarcodeListScannerWithControllerState @@ -170,4 +169,4 @@ class _BarcodeListScannerWithControllerState
170 ), 169 ),
171 ); 170 );
172 } 171 }
173 -}  
  172 +}
@@ -13,12 +13,10 @@ class BarcodeScannerWithController extends StatefulWidget { @@ -13,12 +13,10 @@ class BarcodeScannerWithController extends StatefulWidget {
13 class _BarcodeScannerWithControllerState 13 class _BarcodeScannerWithControllerState
14 extends State<BarcodeScannerWithController> 14 extends State<BarcodeScannerWithController>
15 with SingleTickerProviderStateMixin { 15 with SingleTickerProviderStateMixin {
16 -  
17 BarcodeCapture? barcode; 16 BarcodeCapture? barcode;
18 17
19 MobileScannerController controller = MobileScannerController( 18 MobileScannerController controller = MobileScannerController(
20 - torchEnabled: true,  
21 - detectionSpeed: DetectionSpeed.unrestricted 19 + torchEnabled: true, detectionSpeed: DetectionSpeed.unrestricted,
22 // formats: [BarcodeFormat.qrCode] 20 // formats: [BarcodeFormat.qrCode]
23 // facing: CameraFacing.front, 21 // facing: CameraFacing.front,
24 ); 22 );
@@ -101,7 +99,8 @@ class _BarcodeScannerWithControllerState @@ -101,7 +99,8 @@ class _BarcodeScannerWithControllerState
101 height: 50, 99 height: 50,
102 child: FittedBox( 100 child: FittedBox(
103 child: Text( 101 child: Text(
104 - barcode?.barcodes.first.rawValue ?? 'Scan something!', 102 + barcode?.barcodes.first.rawValue ??
  103 + 'Scan something!',
105 overflow: TextOverflow.fade, 104 overflow: TextOverflow.fade,
106 style: Theme.of(context) 105 style: Theme.of(context)
107 .textTheme 106 .textTheme
@@ -171,4 +170,4 @@ class _BarcodeScannerWithControllerState @@ -171,4 +170,4 @@ class _BarcodeScannerWithControllerState
171 ), 170 ),
172 ); 171 );
173 } 172 }
174 -}  
  173 +}
1 import 'dart:math'; 1 import 'dart:math';
2 -import 'dart:typed_data';  
3 2
4 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
5 import 'package:mobile_scanner/mobile_scanner.dart'; 4 import 'package:mobile_scanner/mobile_scanner.dart';
@@ -27,7 +26,6 @@ class _BarcodeScannerReturningImageState @@ -27,7 +26,6 @@ class _BarcodeScannerReturningImageState
27 26
28 bool isStarted = true; 27 bool isStarted = true;
29 28
30 -  
31 @override 29 @override
32 Widget build(BuildContext context) { 30 Widget build(BuildContext context) {
33 return Scaffold( 31 return Scaffold(
@@ -42,14 +40,21 @@ class _BarcodeScannerReturningImageState @@ -42,14 +40,21 @@ class _BarcodeScannerReturningImageState
42 height: 0.33 * MediaQuery.of(context).size.height, 40 height: 0.33 * MediaQuery.of(context).size.height,
43 child: barcode?.image != null 41 child: barcode?.image != null
44 ? Transform.rotate( 42 ? Transform.rotate(
45 - angle: 90 * pi/180,  
46 - child: Image(  
47 - gaplessPlayback: true,  
48 - image: MemoryImage(barcode!.image!),  
49 - fit: BoxFit.contain,  
50 - ),  
51 - )  
52 - : Container(color: Colors.white, child: const Center(child: Text('Your scanned barcode will appear here!'))), 43 + angle: 90 * pi / 180,
  44 + child: Image(
  45 + gaplessPlayback: true,
  46 + image: MemoryImage(barcode!.image!),
  47 + fit: BoxFit.contain,
  48 + ),
  49 + )
  50 + : Container(
  51 + color: Colors.white,
  52 + child: const Center(
  53 + child: Text(
  54 + 'Your scanned barcode will appear here!',
  55 + ),
  56 + ),
  57 + ),
53 ), 58 ),
54 Container( 59 Container(
55 height: 0.66 * MediaQuery.of(context).size.height, 60 height: 0.66 * MediaQuery.of(context).size.height,
@@ -81,7 +86,9 @@ class _BarcodeScannerReturningImageState @@ -81,7 +86,9 @@ class _BarcodeScannerReturningImageState
81 mainAxisAlignment: MainAxisAlignment.spaceEvenly, 86 mainAxisAlignment: MainAxisAlignment.spaceEvenly,
82 children: [ 87 children: [
83 Container( 88 Container(
84 - color: arguments != null && !arguments!.hasTorch ? Colors.red : Colors.white, 89 + color: arguments != null && !arguments!.hasTorch
  90 + ? Colors.red
  91 + : Colors.white,
85 child: IconButton( 92 child: IconButton(
86 // color: , 93 // color: ,
87 icon: ValueListenableBuilder( 94 icon: ValueListenableBuilder(
@@ -118,7 +125,9 @@ class _BarcodeScannerReturningImageState @@ -118,7 +125,9 @@ class _BarcodeScannerReturningImageState
118 : const Icon(Icons.play_arrow), 125 : const Icon(Icons.play_arrow),
119 iconSize: 32.0, 126 iconSize: 32.0,
120 onPressed: () => setState(() { 127 onPressed: () => setState(() {
121 - isStarted ? controller.stop() : controller.start(); 128 + isStarted
  129 + ? controller.stop()
  130 + : controller.start();
122 isStarted = !isStarted; 131 isStarted = !isStarted;
123 }), 132 }),
124 ), 133 ),
@@ -128,7 +137,8 @@ class _BarcodeScannerReturningImageState @@ -128,7 +137,8 @@ class _BarcodeScannerReturningImageState
128 height: 50, 137 height: 50,
129 child: FittedBox( 138 child: FittedBox(
130 child: Text( 139 child: Text(
131 - barcode?.barcodes.first.rawValue ?? 'Scan something!', 140 + barcode?.barcodes.first.rawValue ??
  141 + 'Scan something!',
132 overflow: TextOverflow.fade, 142 overflow: TextOverflow.fade,
133 style: Theme.of(context) 143 style: Theme.of(context)
134 .textTheme 144 .textTheme
@@ -170,4 +180,4 @@ class _BarcodeScannerReturningImageState @@ -170,4 +180,4 @@ class _BarcodeScannerReturningImageState
170 ), 180 ),
171 ); 181 );
172 } 182 }
173 -}  
  183 +}
@@ -46,7 +46,8 @@ class _BarcodeScannerWithoutControllerState @@ -46,7 +46,8 @@ class _BarcodeScannerWithoutControllerState
46 height: 50, 46 height: 50,
47 child: FittedBox( 47 child: FittedBox(
48 child: Text( 48 child: Text(
49 - capture?.barcodes.first.rawValue ?? 'Scan something!', 49 + capture?.barcodes.first.rawValue ??
  50 + 'Scan something!',
50 overflow: TextOverflow.fade, 51 overflow: TextOverflow.fade,
51 style: Theme.of(context) 52 style: Theme.of(context)
52 .textTheme 53 .textTheme
@@ -66,4 +67,4 @@ class _BarcodeScannerWithoutControllerState @@ -66,4 +67,4 @@ class _BarcodeScannerWithoutControllerState
66 ), 67 ),
67 ); 68 );
68 } 69 }
69 -}  
  70 +}
@@ -23,7 +23,8 @@ class MyHome extends StatelessWidget { @@ -23,7 +23,8 @@ class MyHome extends StatelessWidget {
23 onPressed: () { 23 onPressed: () {
24 Navigator.of(context).push( 24 Navigator.of(context).push(
25 MaterialPageRoute( 25 MaterialPageRoute(
26 - builder: (context) => const BarcodeListScannerWithController(), 26 + builder: (context) =>
  27 + const BarcodeListScannerWithController(),
27 ), 28 ),
28 ); 29 );
29 }, 30 },
@@ -48,14 +49,14 @@ class MyHome extends StatelessWidget { @@ -48,14 +49,14 @@ class MyHome extends StatelessWidget {
48 ); 49 );
49 }, 50 },
50 child: 51 child:
51 - const Text('MobileScanner with Controller (returning image)'), 52 + const Text('MobileScanner with Controller (returning image)'),
52 ), 53 ),
53 ElevatedButton( 54 ElevatedButton(
54 onPressed: () { 55 onPressed: () {
55 Navigator.of(context).push( 56 Navigator.of(context).push(
56 MaterialPageRoute( 57 MaterialPageRoute(
57 builder: (context) => 58 builder: (context) =>
58 - const BarcodeScannerWithoutController(), 59 + const BarcodeScannerWithoutController(),
59 ), 60 ),
60 ); 61 );
61 }, 62 },
@@ -66,4 +67,4 @@ class MyHome extends StatelessWidget { @@ -66,4 +67,4 @@ class MyHome extends StatelessWidget {
66 ), 67 ),
67 ); 68 );
68 } 69 }
69 -}  
  70 +}
@@ -207,8 +207,8 @@ class ContactInfo { @@ -207,8 +207,8 @@ class ContactInfo {
207 /// Create a [ContactInfo] from native data. 207 /// Create a [ContactInfo] from native data.
208 ContactInfo.fromNative(Map data) 208 ContactInfo.fromNative(Map data)
209 : addresses = List.unmodifiable( 209 : addresses = List.unmodifiable(
210 - (data['addresses'] as List).map((e) => Address.fromNative(e as Map)),  
211 - ), 210 + (data['addresses'] as List).map((e) => Address.fromNative(e as Map)),
  211 + ),
212 emails = List.unmodifiable( 212 emails = List.unmodifiable(
213 (data['emails'] as List).map((e) => Email.fromNative(e as Map)), 213 (data['emails'] as List).map((e) => Email.fromNative(e as Map)),
214 ), 214 ),
@@ -768,4 +768,4 @@ enum EncryptionType { @@ -768,4 +768,4 @@ enum EncryptionType {
768 /// 768 ///
769 /// Constant Value: 3 769 /// Constant Value: 3
770 wep, 770 wep,
771 -}  
  771 +}
@@ -10,5 +10,4 @@ class BarcodeCapture { @@ -10,5 +10,4 @@ class BarcodeCapture {
10 required this.barcodes, 10 required this.barcodes,
11 this.image, 11 this.image,
12 }); 12 });
13 -  
14 } 13 }
1 import 'package:flutter/foundation.dart'; 1 import 'package:flutter/foundation.dart';
2 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
  3 +import 'package:mobile_scanner/src/barcode_capture.dart';
3 import 'package:mobile_scanner/src/mobile_scanner_arguments.dart'; 4 import 'package:mobile_scanner/src/mobile_scanner_arguments.dart';
4 import 'package:mobile_scanner/src/mobile_scanner_controller.dart'; 5 import 'package:mobile_scanner/src/mobile_scanner_controller.dart';
5 -import 'package:mobile_scanner/src/barcode_capture.dart';  
6 6
7 /// A widget showing a live camera preview. 7 /// A widget showing a live camera preview.
8 class MobileScanner extends StatefulWidget { 8 class MobileScanner extends StatefulWidget {
@@ -16,9 +16,8 @@ class MobileScanner extends StatefulWidget { @@ -16,9 +16,8 @@ class MobileScanner extends StatefulWidget {
16 /// 16 ///
17 /// [barcode] The barcode object with all information about the scanned code. 17 /// [barcode] The barcode object with all information about the scanned code.
18 /// [startArguments] Information about the state of the MobileScanner widget 18 /// [startArguments] Information about the state of the MobileScanner widget
19 - final Function(  
20 - BarcodeCapture capture, MobileScannerArguments? arguments)  
21 - onDetect; 19 + final Function(BarcodeCapture capture, MobileScannerArguments? arguments)
  20 + onDetect;
22 21
23 /// Handles how the widget should fit the screen. 22 /// Handles how the widget should fit the screen.
24 final BoxFit fit; 23 final BoxFit fit;
@@ -59,7 +58,9 @@ class _MobileScannerState extends State<MobileScanner> @@ -59,7 +58,9 @@ class _MobileScannerState extends State<MobileScanner>
59 void didChangeAppLifecycleState(AppLifecycleState state) { 58 void didChangeAppLifecycleState(AppLifecycleState state) {
60 switch (state) { 59 switch (state) {
61 case AppLifecycleState.resumed: 60 case AppLifecycleState.resumed:
62 - if (!controller.isStarting && widget.autoResume && _lastState != AppLifecycleState.inactive) controller.start(); 61 + if (!controller.isStarting &&
  62 + widget.autoResume &&
  63 + _lastState != AppLifecycleState.inactive) controller.start();
63 break; 64 break;
64 case AppLifecycleState.paused: 65 case AppLifecycleState.paused:
65 case AppLifecycleState.detached: 66 case AppLifecycleState.detached:
@@ -128,4 +129,4 @@ class _MobileScannerState extends State<MobileScanner> @@ -128,4 +129,4 @@ class _MobileScannerState extends State<MobileScanner>
128 WidgetsBinding.instance.removeObserver(this); 129 WidgetsBinding.instance.removeObserver(this);
129 super.dispose(); 130 super.dispose();
130 } 131 }
131 -}  
  132 +}
@@ -5,7 +5,6 @@ import 'package:flutter/cupertino.dart'; @@ -5,7 +5,6 @@ import 'package:flutter/cupertino.dart';
5 import 'package:flutter/foundation.dart'; 5 import 'package:flutter/foundation.dart';
6 import 'package:flutter/services.dart'; 6 import 'package:flutter/services.dart';
7 import 'package:mobile_scanner/mobile_scanner.dart'; 7 import 'package:mobile_scanner/mobile_scanner.dart';
8 -import 'package:mobile_scanner/src/barcode_capture.dart';  
9 import 'package:mobile_scanner/src/barcode_utility.dart'; 8 import 'package:mobile_scanner/src/barcode_utility.dart';
10 import 'package:mobile_scanner/src/mobile_scanner_exception.dart'; 9 import 'package:mobile_scanner/src/mobile_scanner_exception.dart';
11 10
@@ -65,13 +64,13 @@ class MobileScannerController { @@ -65,13 +64,13 @@ class MobileScannerController {
65 64
66 /// Sets the barcode stream 65 /// Sets the barcode stream
67 final StreamController<BarcodeCapture> _barcodesController = 66 final StreamController<BarcodeCapture> _barcodesController =
68 - StreamController.broadcast(); 67 + StreamController.broadcast();
69 Stream<BarcodeCapture> get barcodes => _barcodesController.stream; 68 Stream<BarcodeCapture> get barcodes => _barcodesController.stream;
70 69
71 static const MethodChannel _methodChannel = 70 static const MethodChannel _methodChannel =
72 - MethodChannel('dev.steenbakker.mobile_scanner/scanner/method'); 71 + MethodChannel('dev.steenbakker.mobile_scanner/scanner/method');
73 static const EventChannel _eventChannel = 72 static const EventChannel _eventChannel =
74 - EventChannel('dev.steenbakker.mobile_scanner/scanner/event'); 73 + EventChannel('dev.steenbakker.mobile_scanner/scanner/event');
75 74
76 Function(bool permissionGranted)? onPermissionSet; 75 Function(bool permissionGranted)? onPermissionSet;
77 76
@@ -79,14 +78,15 @@ class MobileScannerController { @@ -79,14 +78,15 @@ class MobileScannerController {
79 late StreamSubscription events; 78 late StreamSubscription events;
80 79
81 /// A notifier that provides several arguments about the MobileScanner 80 /// A notifier that provides several arguments about the MobileScanner
82 - final ValueNotifier<MobileScannerArguments?> startArguments = ValueNotifier(null); 81 + final ValueNotifier<MobileScannerArguments?> startArguments =
  82 + ValueNotifier(null);
83 83
84 /// A notifier that provides the state of the Torch (Flash) 84 /// A notifier that provides the state of the Torch (Flash)
85 final ValueNotifier<TorchState> torchState = ValueNotifier(TorchState.off); 85 final ValueNotifier<TorchState> torchState = ValueNotifier(TorchState.off);
86 86
87 /// A notifier that provides the state of which camera is being used 87 /// A notifier that provides the state of which camera is being used
88 late final ValueNotifier<CameraFacing> cameraFacingState = 88 late final ValueNotifier<CameraFacing> cameraFacingState =
89 - ValueNotifier(facing); 89 + ValueNotifier(facing);
90 90
91 bool isStarting = false; 91 bool isStarting = false;
92 bool? _hasTorch; 92 bool? _hasTorch;
@@ -167,7 +167,8 @@ class MobileScannerController { @@ -167,7 +167,8 @@ class MobileScannerController {
167 if (startResult == null) { 167 if (startResult == null) {
168 isStarting = false; 168 isStarting = false;
169 throw MobileScannerException( 169 throw MobileScannerException(
170 - 'Failed to start mobileScanner, no response from platform side'); 170 + 'Failed to start mobileScanner, no response from platform side',
  171 + );
171 } 172 }
172 173
173 _hasTorch = startResult['torchable'] as bool? ?? false; 174 _hasTorch = startResult['torchable'] as bool? ?? false;
@@ -210,13 +211,14 @@ class MobileScannerController { @@ -210,13 +211,14 @@ class MobileScannerController {
210 Future<void> toggleTorch() async { 211 Future<void> toggleTorch() async {
211 if (_hasTorch == null) { 212 if (_hasTorch == null) {
212 throw MobileScannerException( 213 throw MobileScannerException(
213 - 'Cannot toggle torch if start() has never been called'); 214 + 'Cannot toggle torch if start() has never been called',
  215 + );
214 } else if (!_hasTorch!) { 216 } else if (!_hasTorch!) {
215 throw MobileScannerException('Device has no torch'); 217 throw MobileScannerException('Device has no torch');
216 } 218 }
217 219
218 torchState.value = 220 torchState.value =
219 - torchState.value == TorchState.off ? TorchState.on : TorchState.off; 221 + torchState.value == TorchState.off ? TorchState.on : TorchState.off;
220 222
221 await _methodChannel.invokeMethod('torch', torchState.value.index); 223 await _methodChannel.invokeMethod('torch', torchState.value.index);
222 } 224 }
@@ -227,9 +229,9 @@ class MobileScannerController { @@ -227,9 +229,9 @@ class MobileScannerController {
227 Future<void> switchCamera() async { 229 Future<void> switchCamera() async {
228 await _methodChannel.invokeMethod('stop'); 230 await _methodChannel.invokeMethod('stop');
229 final CameraFacing facingToUse = 231 final CameraFacing facingToUse =
230 - cameraFacingState.value == CameraFacing.back  
231 - ? CameraFacing.front  
232 - : CameraFacing.back; 232 + cameraFacingState.value == CameraFacing.back
  233 + ? CameraFacing.front
  234 + : CameraFacing.back;
233 await start(cameraFacingOverride: facingToUse); 235 await start(cameraFacingOverride: facingToUse);
234 } 236 }
235 237
@@ -272,10 +274,12 @@ class MobileScannerController { @@ -272,10 +274,12 @@ class MobileScannerController {
272 final parsed = (data as List) 274 final parsed = (data as List)
273 .map((value) => Barcode.fromNative(value as Map)) 275 .map((value) => Barcode.fromNative(value as Map))
274 .toList(); 276 .toList();
275 - _barcodesController.add(BarcodeCapture(  
276 - barcodes: parsed,  
277 - image: event['image'] as Uint8List,  
278 - )); 277 + _barcodesController.add(
  278 + BarcodeCapture(
  279 + barcodes: parsed,
  280 + image: event['image'] as Uint8List,
  281 + ),
  282 + );
279 break; 283 break;
280 case 'barcodeMac': 284 case 'barcodeMac':
281 _barcodesController.add( 285 _barcodesController.add(
@@ -289,11 +293,15 @@ class MobileScannerController { @@ -289,11 +293,15 @@ class MobileScannerController {
289 ); 293 );
290 break; 294 break;
291 case 'barcodeWeb': 295 case 'barcodeWeb':
292 - _barcodesController.add(BarcodeCapture(barcodes: [  
293 - Barcode(  
294 - rawValue: data as String?,  
295 - )  
296 - ])); 296 + _barcodesController.add(
  297 + BarcodeCapture(
  298 + barcodes: [
  299 + Barcode(
  300 + rawValue: data as String?,
  301 + )
  302 + ],
  303 + ),
  304 + );
297 break; 305 break;
298 case 'error': 306 case 'error':
299 throw MobileScannerException(data as String); 307 throw MobileScannerException(data as String);
@@ -301,4 +309,4 @@ class MobileScannerController { @@ -301,4 +309,4 @@ class MobileScannerController {
301 throw UnimplementedError(name as String?); 309 throw UnimplementedError(name as String?);
302 } 310 }
303 } 311 }
304 -}  
  312 +}