Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access image in Android from Flutter?

I have a Flutter project that works well on both the iOS and Android platform.

In the Flutter project, there is an image located in android/app/src/main/res/mipmap-xxhdpi/temp.jpg,

and I want to load that image and use it in the Flutter widget.

I have tried to find answer in the document Adding assets and images and Flutter for Android developers but no luck.

How to do that? Thanks.

like image 675
Shan Avatar asked Mar 11 '26 08:03

Shan


1 Answers

Just like @jabamataro mentioned in the comments, define the path - android/app/src/main/res/mipmap-xxhdpi/ in the assets: section of the pubspec.yaml file like below:

assets:
    - android/app/src/main/res/mipmap-xxhdpi/

then the image could be used like:

AssetImage('android/app/src/main/res/mipmap-xxhdpi/temp.jpg');  

Hope this answer can help those new to Flutter development.

like image 189
Shan Avatar answered Mar 13 '26 00:03

Shan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!