'Image from device path not shown

I have downloaded a file to getApplicationDocumentsDirectory(). Then I have inserted the file path to a SQLite database.

In this case the file is a png file, and I need to show it on a screen.

I am trying to do it as follows:

Container(color: Colors.grey[200],
          child: Image.file(File(${snapshot.data![position].path})),
                                  alignment: Alignment.center

)

I am geting an exception:

FileSystemException: Cannot open file, path=//var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png

I have checked if the path from the downloaded file is equal to the path from the SQLite item value, and both are equal.

Downloaded file path print output:

flutter: path al archivo descargado /var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png

SQLite path value :

path en docs:  /var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png

I have also tested putting that path as text directly into

Image.file(File("/var/mobile/Containers/Data/Application/B2663D60-9BEF-4FFF-9287-BFD3CE6EF8BE/Documents/AgdsBeviewlogomodesto.png"))

and it works.

I don´t find the reason for not showing the image when using the value snapshot.data![position].path, knowing that it is the same value.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source