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
1

2 Answers 2

17

The way is to use :

new Image.file(File(imagePath))

see stackoverflow questions

Sign up to request clarification or add additional context in comments.

Comments

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)),
              )

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.