Преглед изворни кода

Reformat with dartfmt

flutter-beta
Julian Steenbakker пре 5 година
родитељ
комит
4a429d61a3
No known key found for this signature in database GPG Key ID: 16E437C7A3D94250
2 измењених фајлова са 16 додато и 8 уклоњено
  1. +6
    -2
      example/lib/main.dart
  2. +10
    -6
      lib/src/qr_code_scanner.dart

+ 6
- 2
example/lib/main.dart Прегледај датотеку

@@ -148,12 +148,16 @@ class _QRViewExampleState extends State<QRViewExample> {

Widget _buildQrView(BuildContext context) {
// For this example we check how width or tall the device is and change the scanArea and overlay accordingly.
double scanArea = (MediaQuery.of(context).size.width < 500 || MediaQuery.of(context).size.height < 400) ? 150 : 300;
double scanArea = (MediaQuery.of(context).size.width < 500 ||
MediaQuery.of(context).size.height < 400)
? 150
: 300;
// To ensure the Scanner view is properly sizes after rotation
// we need to listen for Flutter SizeChanged notification and update controller
return NotificationListener<SizeChangedLayoutNotification>(
onNotification: (notification) {
Future.microtask(() => controller?.updateDimensions(qrKey, scanArea: scanArea));
Future.microtask(
() => controller?.updateDimensions(qrKey, scanArea: scanArea));
return false;
},
child: SizeChangedLayoutNotifier(


+ 10
- 6
lib/src/qr_code_scanner.dart Прегледај датотеку

@@ -138,7 +138,9 @@ class _QRViewState extends State<QRView> {
_platformQrView = UiKitView(
viewType: 'net.touchcapture.qr.flutterqr/qrview',
onPlatformViewCreated: _onPlatformViewCreated,
creationParams: _CreationParams.fromWidget(MediaQuery.of(context).size.width, 400).toMap(),
creationParams:
_CreationParams.fromWidget(MediaQuery.of(context).size.width, 400)
.toMap(),
creationParamsCodec: StandardMessageCodec(),
);
break;
@@ -154,7 +156,8 @@ class _QRViewState extends State<QRView> {
return;
}

widget.onQRViewCreated(QRViewController._(id, widget.key, (widget.overlay as QrScannerOverlayShape).cutOutSize));
widget.onQRViewCreated(QRViewController._(
id, widget.key, (widget.overlay as QrScannerOverlayShape).cutOutSize));
}
}

@@ -236,10 +239,11 @@ class QRViewController {
void updateDimensions(GlobalKey key, {double scanArea}) {
if (defaultTargetPlatform == TargetPlatform.iOS) {
final RenderBox renderBox = key.currentContext.findRenderObject();
_channel.invokeMethod('setDimensions',
{'width': renderBox.size.width,
'height': renderBox.size.height,
'scanArea': scanArea?? 0});
_channel.invokeMethod('setDimensions', {
'width': renderBox.size.width,
'height': renderBox.size.height,
'scanArea': scanArea ?? 0
});
}
}
}

Loading…
Откажи
Сачувај