如何在 Flutter 中生成二维码并将其显示在 PDF 页面上 [英] How Can I generate QR code and Show it on a PDF page in Flutter

查看:82
本文介绍了如何在 Flutter 中生成二维码并将其显示在 PDF 页面上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个 Flutter 应用程序,其中一个功能包括:

I am Building a Flutter App, and one of the Functionalities includes the following:

1- 生成二维码 - 如果我在屏幕上显示它,这里没有问题.2- 生成 PDF 文件,然后保存并使用本机设备共享共享,这里没问题,直到我尝试在 PDF 页面中包含二维码!

1- Generating Qr codes - no problem here if I am showing it on the screen. 2- Generating PDF file, then saving it and sharing it using native device Sharing, No problem here until I tried to include the Qr code in the PDF page!

我已经坚持了两天并尝试了太多方法来解决这个问题,遗憾的是没有运气.

I have been stuck with this for two days and tried too many approaches to solve this, sadly with no luck.

请提前帮助并感谢大家.

please help and thank you all in advance.

推荐答案

您可以使用 pdf 包中的 Barcode 小部件.https://pub.dev/packages/pdf

You can use the Barcode widget from the pdf package. https://pub.dev/packages/pdf

import 'package:pdf/widgets.dart' as pw;

//Barcode widget inside pdf.addPage()
pw.BarcodeWidget(
  color: PdfColor.fromHex("#000000"),
  barcode: pw.Barcode.qrCode(),
  data: "My data",
),

这篇关于如何在 Flutter 中生成二维码并将其显示在 PDF 页面上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆