首页 > 解决方案 > 如何在颤振中以base64显示pdf?

问题描述

我有 base64 格式的 pdf 内容,我需要在颤振应用程序的容器中显示它。

我正在尝试使用图像、pdf 并从 dart 转换包,但图像类出现错误,我不知道如何显示图像。

List<int> pdfDataBytes = base64.decode(fileContent);
  Image img = decodeImage(pdfDataBytes);
  PdfImage image = PdfImage(
    pdf,
    image: img.data.buffer.asUint8List(),
    width: img.width,
    height: img.height);

这是图像类中的错误消息:尝试对其中一个导入指令使用“作为前缀”,或者对除一个导入之外的所有导入指令隐藏名称

标签: imagepdfflutterdart

解决方案


我没有测试它,但你有显示 pdf 的颤振包:flutter full pdf viewer 你可以在这里找到一个使用这个包和 pdf 资产的例子。


推荐阅读