问题
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