How can I show a pdf in base64 in flutter?

ε祈祈猫儿з 提交于 2021-02-18 17:09:20

问题


I have the content of a pdf in base64 and I need to show it in a container in a flutter application.

I'm trying to do it with the image, pdf and convert packages from dart,but I get an error with the image class and I don't know how to show the image.

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);

This is the message of the error in the image class: Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports


回答1:


I didn't test it but you have flutter package displaying pdf : flutter full pdf viewer You can find here an example of using this package with a pdf asset.




回答2:


This error means you have a duplicate import for Image.



来源:https://stackoverflow.com/questions/56939473/how-can-i-show-a-pdf-in-base64-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!