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
Flutter comes with an image picker plugin for picking images from the device gallery or taking new pictures from the camera. The image_picker plugin exposes some helpful methods from the ImagePicker class it exports: import 'package:image_picker/image_picker. dart'; ImagePicker picker = ImagePicker();
The way is to use :
new Image.file(File(imagePath))
see stackoverflow questions
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)),
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With