Bläddra i källkod

Globalkey gets added in Widget creation

flutter-beta
Luis Thein 7 år sedan
förälder
incheckning
8f1c4256dc
2 ändrade filer med 5 tillägg och 4 borttagningar
  1. +2
    -0
      example/lib/main.dart
  2. +3
    -4
      lib/qr_code_scanner.dart

+ 2
- 0
example/lib/main.dart Visa fil

@@ -22,6 +22,7 @@ class _QRViewExampleState extends State<QRViewExample> {
var flashState = flash_on;
var cameraState = front_camera;
QRViewController controller;
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');

@override
Widget build(BuildContext context) {
@@ -30,6 +31,7 @@ class _QRViewExampleState extends State<QRViewExample> {
children: <Widget>[
Expanded(
child: QRView(
key: qrKey,
onQRViewCreated: _onQRViewCreated,
),
flex: 4,


+ 3
- 4
lib/qr_code_scanner.dart Visa fil

@@ -8,8 +8,8 @@ typedef void QRViewCreatedCallback(QRViewController controller);

class QRView extends StatefulWidget {
const QRView({
Key key,
this.onQRViewCreated,
@required Key key,
@required this.onQRViewCreated,
}) : super(key: key);

final QRViewCreatedCallback onQRViewCreated;
@@ -19,7 +19,6 @@ class QRView extends StatefulWidget {
}

class _QRViewState extends State<QRView> {
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
@override
Widget build(BuildContext context) {
var androidView = AndroidView(
@@ -48,7 +47,7 @@ class _QRViewState extends State<QRView> {
if (widget.onQRViewCreated == null) {
return;
}
widget.onQRViewCreated(QRViewController._(id, qrKey));
widget.onQRViewCreated(QRViewController._(id, widget.key));
}
}



Laddar…
Avbryt
Spara