Search code examples
flutterimagedisplayprovider

Flutter Image not displaying


I have added images on assets folder/images. So I'm trying to make a page with an image banner and this is my code:

Container(
          height: 120,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(10.0),
            image: const DecorationImage(
              image: AssetImage("assets/images/drive.png"),
              fit: BoxFit.fill,
            ),
          ),
        ),



# To add assets to your application, add an assets section, like this:

assets: - assets/images/

- images/a_dot_ham.jpeg


Solution

  • Make sure that extension of image in your project is exactly same with those images which you added in asset folders. (.jpeg,.jpg or .png) Must check pubspec file. Then do run one time pub get command in pubspec file. Still you can't see an image in your app then go File -> Invalidate Caches / Restart.

    (You can use Image.asset also instead of AssetImage too.)