The QR Code Scanner package for Appeto SDK.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

54 řádky
1.3 KiB

  1. import 'package:flutter/material.dart';
  2. import 'package:flutter/services.dart';
  3. import 'package:qr_code_scanner/qr_code_scanner.dart';
  4. void main() => runApp(MaterialApp(home: TextViewExample()));
  5. class TextViewExample extends StatefulWidget {
  6. const TextViewExample({
  7. Key key,
  8. }) : super(key: key);
  9. @override
  10. State<StatefulWidget> createState() => _TextViewExampleState();
  11. }
  12. class _TextViewExampleState extends State<TextViewExample> {
  13. final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
  14. var qrText = "";
  15. @override
  16. Widget build(BuildContext context) {
  17. return Scaffold(
  18. body: Column(
  19. children: <Widget>[
  20. Expanded(
  21. child: QRView(
  22. key: qrKey,
  23. onQRViewCreated: _onQRViewCreated,
  24. ),
  25. flex: 1,
  26. ),
  27. Expanded(
  28. child: Text("This is the result of scan: $qrText"),
  29. flex: 4,
  30. )
  31. ],
  32. ),
  33. );
  34. }
  35. void _onQRViewCreated(QRViewController controller) {
  36. final channel = controller.channel;
  37. controller.init(qrKey);
  38. channel.setMethodCallHandler((MethodCall call) async {
  39. switch (call.method) {
  40. case "onRecognizeQR":
  41. dynamic arguments = call.arguments;
  42. setState(() {
  43. qrText = arguments.toString();
  44. });
  45. }
  46. });
  47. }
  48. }