Home > OS >  Flutter : image assets are not showing in android build
Flutter : image assets are not showing in android build

Time:06-20

I am trying a simple flutter app. It is working fine on web. But on android, images can't load.

this is my pubspec.yaml

flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - images/
    - gif/

I have images and gif folders at root of project.

and I am loading images like this

child: Image(image: AssetImage("/images/abc.jpg"),
or 
child: Image(image: AssetImage("/gif/abc.gif"),

This works fine when I run on IDE, but on making android apk, images and gif are not showing.

In android folder, there is no assets directory as well. I have tired flutter clean and flutter create . but no luck.

CodePudding user response:

You need to use like this

Image(image: AssetImage("images/abc.jpg")),
  • Related