Julian Steenbakker

style: flutter format

... ... @@ -18,8 +18,10 @@ class _AnalyzeViewState extends State<AnalyzeView>
with SingleTickerProviderStateMixin {
String? barcode;
MobileScannerController controller = MobileScannerController(torchEnabled: true,
facing: CameraFacing.front,);
MobileScannerController controller = MobileScannerController(
torchEnabled: true,
facing: CameraFacing.front,
);
@override
Widget build(BuildContext context) {
... ... @@ -60,9 +62,11 @@ class _AnalyzeViewState extends State<AnalyzeView>
builder: (context, state, child) {
switch (state as TorchState) {
case TorchState.off:
return const Icon(Icons.flash_off, color: Colors.grey);
return const Icon(Icons.flash_off,
color: Colors.grey);
case TorchState.on:
return const Icon(Icons.flash_on, color: Colors.yellow);
return const Icon(Icons.flash_on,
color: Colors.yellow);
}
},
),
... ...
... ... @@ -48,9 +48,10 @@ class _AnalyzeViewState extends State<AnalyzeView>
final size = MediaQuery.of(context).devicePixelRatio;
debugPrint('Size: ${barcode.corners}');
for (var point in barcode.corners!) {
final adjustedWith = point.dx ;
final adjustedHeight= point.dy ;
points.add(Offset(adjustedWith / size, adjustedHeight / size));
final adjustedWith = point.dx;
final adjustedHeight = point.dy;
points.add(
Offset(adjustedWith / size, adjustedHeight / size));
// points.add(Offset((point.dx ) / size,
// (point.dy) / size));
// final differenceWidth = (args.wantedSize!.width - args.size.width) / 2;
... ...
... ... @@ -3,10 +3,7 @@ import 'package:mobile_scanner/mobile_scanner.dart';
import 'mobile_scanner_arguments.dart';
enum Ratio {
ratio_4_3,
ratio_16_9
}
enum Ratio { ratio_4_3, ratio_16_9 }
/// A widget showing a live camera preview.
class MobileScanner extends StatefulWidget {
... ... @@ -18,7 +15,8 @@ class MobileScanner extends StatefulWidget {
/// Create a [MobileScanner] with a [controller], the [controller] must has been initialized.
const MobileScanner(
{Key? key, this.onDetect, this.controller, this.fit = BoxFit.cover})
: assert((controller != null )), super(key: key);
: assert((controller != null)),
super(key: key);
@override
State<MobileScanner> createState() => _MobileScannerState();
... ...
... ... @@ -11,5 +11,6 @@ class MobileScannerArguments {
final bool hasTorch;
/// Create a [MobileScannerArguments].
MobileScannerArguments({required this.textureId,required this.size, required this.hasTorch});
MobileScannerArguments(
{required this.textureId, required this.size, required this.hasTorch});
}
... ...
... ... @@ -38,7 +38,6 @@ class MobileScannerController {
int? _controllerHashcode;
StreamSubscription? events;
final ValueNotifier<MobileScannerArguments?> args = ValueNotifier(null);
final ValueNotifier<TorchState> torchState = ValueNotifier(TorchState.off);
late final ValueNotifier<CameraFacing> cameraFacingState;
... ... @@ -107,7 +106,8 @@ class MobileScannerController {
setAnalyzeMode(AnalyzeMode.barcode.index);
// Check authorization status
MobileScannerState state = MobileScannerState.values[await methodChannel.invokeMethod('state')];
MobileScannerState state =
MobileScannerState.values[await methodChannel.invokeMethod('state')];
switch (state) {
case MobileScannerState.undetermined:
final bool result = await methodChannel.invokeMethod('request');
... ... @@ -129,13 +129,17 @@ class MobileScannerController {
if (torchEnabled != null) arguments['torch'] = torchEnabled;
// Start the camera with arguments
final Map<String, dynamic>? startResult = await methodChannel.invokeMapMethod<String, dynamic>(
'start', arguments);
final Map<String, dynamic>? startResult = await methodChannel
.invokeMapMethod<String, dynamic>('start', arguments);
if (startResult == null) throw PlatformException(code: 'INITIALIZATION ERROR');
if (startResult == null)
throw PlatformException(code: 'INITIALIZATION ERROR');
hasTorch = startResult['torchable'];
args.value = MobileScannerArguments(textureId: startResult['textureId'], size: toSize(startResult['size']), hasTorch: hasTorch);
args.value = MobileScannerArguments(
textureId: startResult['textureId'],
size: toSize(startResult['size']),
hasTorch: hasTorch);
}
Future<void> stop() async => await methodChannel.invokeMethod('stop');
... ... @@ -157,7 +161,8 @@ class MobileScannerController {
Future<void> switchCamera() async {
ensure('switchCamera');
await stop();
facing = facing == CameraFacing.back ? CameraFacing.front : CameraFacing.back;
facing =
facing == CameraFacing.back ? CameraFacing.front : CameraFacing.back;
start();
}
... ...
... ... @@ -16,5 +16,4 @@ void main() {
tearDown(() {
channel.setMockMethodCallHandler(null);
});
}
... ...