How to use Network Image in PDF Flutter

Viewed 620

I have a database document where there is links available for multiple images. I want to display this images in pdf.

I am using pdf: ^2.1.0 to edit the pdf file and flutter_pdfview: ^1.0.1 to view the pdf.

I am currently displaying images like this but this can only display images from the asset

final profileImage = pw.MemoryImage(
  (await rootBundle.load('assets/images/image.png')).buffer.asUint8List(),
);

//Inside Widgets
pw.Image(profileImage)

I want to show images using a link but its not being possible.

1 Answers

This will help you

var response = await http.get(Uri.parse(imageUrl));
var data = response.bodyBytes;

Image(pdfW.MemoryImage(data),)
Related