7

I have generated an image using the Flutter camera plugin. I am trying to display it.

My path looks like:

/data/user/0/com.example.myapp/app_flutter/picture2.jpg

How should I load it ?

I tried :

new Image.network("file:///"+imagePath)

but I get the error :

Another exception was thrown: Invalid argument(s): No host specified in URI file:////data/user/0/com.example.myapp/app_flutter/picture2.jpg
gpasse
  • 4,380
  • 7
  • 44
  • 75
  • Use `Image.file(path}` instead https://stackoverflow.com/questions/49835623/how-to-load-images-in-flutter-with-image-file?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Günter Zöchbauer May 16 '18 at 18:09

2 Answers2

16

The way is to use :

new Image.file(File(imagePath))

see stackoverflow questions

gpasse
  • 4,380
  • 7
  • 44
  • 75
2

Use FileImage like below. It takes the File as the parameter.

 _image = File(path);

Container(
               padding: const EdgeInsets.all(1.0),
               decoration: BoxDecoration(
               color: Colors.white,
               image: DecorationImage(
                          image: FileImage(_image), fit: BoxFit.cover)),
              )
Amir
  • 1,855
  • 3
  • 24
  • 40