@@ -87,23 +87,21 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
8787 return null ;
8888 }
8989
90- final Object ? data = event['data' ];
90+ final data = event['data' ];
9191
9292 if (data == null || data is ! List <Object ?>) {
9393 return null ;
9494 }
9595
96- final List <Map <Object ?, Object ?>> barcodes =
97- data.cast <Map <Object ?, Object ?>>();
96+ final barcodes = data.cast <Map <Object ?, Object ?>>();
9897
9998 if (defaultTargetPlatform == TargetPlatform .android ||
10099 defaultTargetPlatform == TargetPlatform .iOS ||
101100 defaultTargetPlatform == TargetPlatform .macOS) {
102- final Map <Object ?, Object ?>? imageData =
103- event['image' ] as Map <Object ?, Object ?>? ;
104- final Uint8List ? image = imageData? ['bytes' ] as Uint8List ? ;
105- final double ? width = imageData? ['width' ] as double ? ;
106- final double ? height = imageData? ['height' ] as double ? ;
101+ final imageData = event['image' ] as Map <Object ?, Object ?>? ;
102+ final image = imageData? ['bytes' ] as Uint8List ? ;
103+ final width = imageData? ['width' ] as double ? ;
104+ final height = imageData? ['height' ] as double ? ;
107105
108106 return BarcodeCapture (
109107 raw: event,
@@ -143,10 +141,9 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
143141 /// Throws a [MobileScannerException] if the permission is not granted.
144142 Future <void > _requestCameraPermission () async {
145143 try {
146- final MobileScannerAuthorizationState authorizationState =
147- MobileScannerAuthorizationState .fromRawValue (
148- await methodChannel.invokeMethod <int >('state' ) ?? 0 ,
149- );
144+ final authorizationState = MobileScannerAuthorizationState .fromRawValue (
145+ await methodChannel.invokeMethod <int >('state' ) ?? 0 ,
146+ );
150147
151148 switch (authorizationState) {
152149 // Authorization was already granted, no need to request it again.
@@ -156,7 +153,7 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
156153 // So if the permission was denied, request it again.
157154 case MobileScannerAuthorizationState .denied:
158155 case MobileScannerAuthorizationState .undetermined:
159- final bool permissionGranted =
156+ final permissionGranted =
160157 await methodChannel.invokeMethod <bool >('request' ) ?? false ;
161158
162159 if (! permissionGranted) {
@@ -209,17 +206,19 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
209206 List <BarcodeFormat > formats = const < BarcodeFormat > [],
210207 }) async {
211208 try {
212- final Map <Object ?, Object ?>? result = await methodChannel
213- .invokeMapMethod <Object ?, Object ?>('analyzeImage' , {
214- 'filePath' : path,
215- 'formats' :
216- formats.isEmpty
217- ? null
218- : [
219- for (final BarcodeFormat format in formats)
220- if (format != BarcodeFormat .unknown) format.rawValue,
221- ],
222- });
209+ final result = await methodChannel.invokeMapMethod <Object ?, Object ?>(
210+ 'analyzeImage' ,
211+ {
212+ 'filePath' : path,
213+ 'formats' :
214+ formats.isEmpty
215+ ? null
216+ : [
217+ for (final BarcodeFormat format in formats)
218+ if (format != BarcodeFormat .unknown) format.rawValue,
219+ ],
220+ },
221+ );
223222
224223 return _parseBarcode (result);
225224 } on PlatformException catch (error) {
@@ -282,7 +281,7 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
282281 throw UnimplementedError ('setFocusPoint() has not been implemented.' );
283282 }
284283
285- final Map < String , Object ?> params = < String , Object ? > {
284+ final params = < String , Object ? > {
286285 'dx' : position.dx,
287286 'dy' : position.dy,
288287 };
@@ -330,7 +329,7 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
330329 );
331330 }
332331
333- final int ? textureId = startResult['textureId' ] as int ? ;
332+ final textureId = startResult['textureId' ] as int ? ;
334333
335334 if (textureId == null ) {
336335 throw const MobileScannerException (
@@ -341,7 +340,7 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
341340 );
342341 }
343342
344- final CameraFacing cameraDirection = CameraFacing .fromRawValue (
343+ final cameraDirection = CameraFacing .fromRawValue (
345344 startResult['cameraDirection' ] as int ? ,
346345 );
347346
@@ -364,8 +363,8 @@ class MethodChannelMobileScanner extends MobileScannerPlatform {
364363 initialDeviceOrientation = orientation.parseDeviceOrientation ();
365364 }
366365
367- final int ? numberOfCameras = startResult['numberOfCameras' ] as int ? ;
368- final TorchState currentTorchState = TorchState .fromRawValue (
366+ final numberOfCameras = startResult['numberOfCameras' ] as int ? ;
367+ final currentTorchState = TorchState .fromRawValue (
369368 startResult['currentTorchState' ] as int ? ?? - 1 ,
370369 );
371370
0 commit comments