flutter open images from file path

I am using image_picker to get some images from gallery, and I saved the path of the images in a list, like:

/private/var/mobile/Containers/Data/Application/E633FB78-77D3-4913-B37A-496BFBAAD00C/tmp/image_picker_EA6D2836-3EAD-438C-AEEE-21CB3500ED28-9410-00000706FA96031D.jpg

how can I open the image from the path in flutter?

I tried Image.file, but it doesn't work, please help.


Solution 1:

The Image class has a file constructor for that

https://api.flutter.dev/flutter/widgets/Image/Image.file.html

Image.file(File(path))

Solution 2:

I had the same problem, and I solved it with the following code:
Image.file(new File(StringPathVariable)

Solution 3:

If I remember correctly Image.file() can only accept ImageProvider<Object>, and apparently File(imagePath) is categorized as Image type

So if Image.file(File(imagePath)) fail, you can add .image at the end to turn it into ImageProvider<Object>, so the following code should work:

Image.file(File(imageUri)).image