Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load image if there is a space in path or name file Flutter

Tags:

flutter

I have a problem with a load dynamically an Asset image.

I have an image and I'm trying to load with:

new AssetImage(img_path)

The img_path is:

/storage/emulated/0/WhatsApp/Media/WhatsApp Images/test.jpg

And it return:

(27161): Another exception was thrown: Unable to load asset: /storage/emulated/0/WhatsApp/Media/WhatsApp Images/test.jpg

If i try to move my file for example in

/storage/emulated/0/WhatsApp/Media/test.jpg

It works.

But not if I change name of my file with space for example:

/storage/emulated/0/WhatsApp/Media/test with space.jpg

So I guess that It can be a problem with a space in path.

How can I solve this?

like image 732
LorenzoBerti Avatar asked Sep 12 '18 12:09

LorenzoBerti


1 Answers

I assume this is what you actually want

new FileImage(
    new File('/storage/emulated/0/WhatsApp/Media/WhatsApp Images/test.jpg')
)

See also https://docs.flutter.io/flutter/painting/FileImage-class.html

like image 107
Günter Zöchbauer Avatar answered Nov 10 '22 15:11

Günter Zöchbauer