Julian Steenbakker

style: flutter format .

... ... @@ -26,7 +26,6 @@ class _BarcodeScannerWithScanWindowState
@override
Widget build(BuildContext context) {
final query = MediaQuery.of(context);
final scanWindow = Rect.fromCenter(
center: MediaQuery.of(context).size.center(Offset.zero),
width: 200,
... ... @@ -54,7 +53,13 @@ class _BarcodeScannerWithScanWindowState
barcode?.corners != null &&
arguments != null)
CustomPaint(
painter: BarcodeOverlay(barcode!, arguments!, BoxFit.contain, MediaQuery.of(context).devicePixelRatio, capture!),
painter: BarcodeOverlay(
barcode!,
arguments!,
BoxFit.contain,
MediaQuery.of(context).devicePixelRatio,
capture!,
),
),
CustomPaint(
painter: ScannerOverlay(scanWindow),
... ... @@ -126,7 +131,13 @@ class ScannerOverlay extends CustomPainter {
}
class BarcodeOverlay extends CustomPainter {
BarcodeOverlay(this.barcode, this.arguments, this.boxFit, this.devicePixelRatio, this.capture);
BarcodeOverlay(
this.barcode,
this.arguments,
this.boxFit,
this.devicePixelRatio,
this.capture,
);
final BarcodeCapture capture;
final Barcode barcode;
... ... @@ -153,13 +164,21 @@ class BarcodeOverlay extends CustomPainter {
horizontalPadding = 0;
}
final ratioWidth = (Platform.isIOS ? capture.width! : arguments.size.width)/ adjustedSize.destination.width;
final ratioHeight = (Platform.isIOS ? capture.height! : arguments.size.height) / adjustedSize.destination.height;
final ratioWidth =
(Platform.isIOS ? capture.width! : arguments.size.width) /
adjustedSize.destination.width;
final ratioHeight =
(Platform.isIOS ? capture.height! : arguments.size.height) /
adjustedSize.destination.height;
final List<Offset> adjustedOffset = [];
for (final offset in barcode.corners!) {
adjustedOffset.add(Offset(offset.dx / ratioWidth + horizontalPadding,
offset.dy / ratioHeight + verticalPadding));
adjustedOffset.add(
Offset(
offset.dx / ratioWidth + horizontalPadding,
offset.dy / ratioHeight + verticalPadding,
),
);
}
final cutoutPath = Path()..addPolygon(adjustedOffset, true);
... ...
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart' hide applyBoxFit;
import 'package:flutter/material.dart';
import 'package:mobile_scanner/src/mobile_scanner_controller.dart';
import 'package:mobile_scanner/src/objects/barcode_capture.dart';
... ... @@ -145,7 +144,8 @@ class _MobileScannerState extends State<MobileScanner>
/// create a new rectangle that represents the texture on the screen
final minX = widgetSize.width / 2 - fittedTextureSize.destination.width / 2;
final minY = widgetSize.height / 2 - fittedTextureSize.destination.height / 2;
final minY =
widgetSize.height / 2 - fittedTextureSize.destination.height / 2;
final textureWindow = Offset(minX, minY) & fittedTextureSize.destination;
/// create a new scan window and with only the area of the rect intersecting the texture window
... ... @@ -161,10 +161,14 @@ class _MobileScannerState extends State<MobileScanner>
final windowInTexture = Rect.fromLTWH(newLeft, newTop, newWidth, newHeight);
/// get the scanWindow as a percentage of the texture
final percentageLeft = windowInTexture.left / fittedTextureSize.destination.width;
final percentageTop = windowInTexture.top / fittedTextureSize.destination.height;
final percentageRight = windowInTexture.right / fittedTextureSize.destination.width;
final percentagebottom = windowInTexture.bottom / fittedTextureSize.destination.height;
final percentageLeft =
windowInTexture.left / fittedTextureSize.destination.width;
final percentageTop =
windowInTexture.top / fittedTextureSize.destination.height;
final percentageRight =
windowInTexture.right / fittedTextureSize.destination.width;
final percentagebottom =
windowInTexture.bottom / fittedTextureSize.destination.height;
/// this rectangle can be send to native code and used to cut out a rectangle of the scan image
return Rect.fromLTRB(
... ... @@ -197,7 +201,6 @@ class _MobileScannerState extends State<MobileScanner>
_controller.updateScanWindow(window);
}
return ClipRect(
child: LayoutBuilder(
builder: (_, constraints) {
... ... @@ -219,7 +222,7 @@ class _MobileScannerState extends State<MobileScanner>
);
},
);
}
},
);
}
... ...
... ... @@ -20,6 +20,6 @@ class BarcodeCapture {
required this.barcodes,
this.image,
this.width,
this.height
this.height,
});
}
... ...