1、加入依赖

在 pubspec.yaml 中 dependencies 节点下添加:

dependencies:
qr_flutter: ^1.1.6

 

2、引入代码

在需要细线二维码的 dart 类中引入依赖代码包:

import 'package:qr_flutter/qr_flutter.dart';

 

代码部分

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

/**
 * 首页
 */
class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage>
    with AutomaticKeepAliveClientMixin { // 切换界面保持,不被重置

  @override
  bool get wantKeepAlive => true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: new AppBar(
        title: new Text("我是标题"),
      ),
      body: new Center(
        child: new QrImage(
          data: "这里是需要生成二维码的数据",
          size: 200.0,
      ),
      ),
    );
  }
}

 

详细属性:https://pub.dartlang.org/packages/qr_flutter

Flutter 实现 生成二维码

 

3、实现效果

Flutter 实现 生成二维码

 

博客地址:https://www.cnblogs.com/niceyoo

 

相关文章:

  • 2021-12-03
  • 2021-11-25
  • 2021-11-14
  • 2022-12-23
  • 2022-01-13
  • 2022-02-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-19
  • 2021-12-26
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案