QRTest

import 'package:flutter/material.dart';
import 'package:qr_utils/qr_utils.dart';

class QRWidget extends StatefulWidget {
  @override
  _QRWidgetState createState() => _QRWidgetState();
}

class _QRWidgetState extends State<QRWidget> {
  String _content = "";

  @override
  Widget build(BuildContext context) {
    return Container(
      child: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            RaisedButton(
              child: Text('识别二维码'),
              onPressed: _scanQR,
            ),
            Text(_content),
          ],
        ),
      ),
    );
  }

  void _scanQR() async {
    String result;
    try {
      result = await QrUtils.scanQR;
    } catch (e) {
      result = 'Process Failed!';
    }

    setState(() {
      _content = result;
    });
  }
}

  

posted @ 2019-08-16 06:11  caobingkun  阅读(107)  评论(0编辑  收藏  举报