如何在 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",
),