qr_code_scanner 0.0.1 copy "qr_code_scanner: ^0.0.1" to clipboard
qr_code_scanner: ^0.0.1 copied to clipboard

outdated

QR code scanner natively embedded inside flutter.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:qr_code_scanner/qr_code_scanner.dart';

void main() => runApp(MaterialApp(home: TextViewExample()));

class TextViewExample extends StatefulWidget {
  const TextViewExample({
    Key key,
  }) : super(key: key);

  @override
  State<StatefulWidget> createState() => _TextViewExampleState();
}

class _TextViewExampleState extends State<TextViewExample> {
  final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
  var qrText = "";
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: <Widget>[
          Expanded(
            child: QRView(
              key: qrKey,
              onQRViewCreated: _onQRViewCreated,
            ),
            flex: 1,
          ),
          Expanded(
            child: Text("This is the result of scan: $qrText"),
            flex: 4,
          )
        ],
      ),
    );
  }

  void _onQRViewCreated(QRViewController controller) {
    final channel = controller.channel;
    controller.init(qrKey);
    channel.setMethodCallHandler((MethodCall call) async {
      switch (call.method) {
        case "onRecognizeQR":
          dynamic arguments = call.arguments;
          setState(() {
            qrText = arguments.toString();
          });
      }
    });
  }
}
1992
likes
0
pub points
100%
popularity

Publisher

unverified uploader

QR code scanner natively embedded inside flutter.

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on qr_code_scanner