Flutter program not showing images

Viewed 92

I am working on project in flutter but facing issue with images. I have saved images in assets folder and provided the path in actual code but they are not visible in actual application.

ASSETS:

assets:

  • assets/images/Chicken.png
  • assets/images/veg.png

Application code where I've put images:

import '../models/category_model.dart';

final categories = [
  Category(
    numberOfItems: 43,
    imagePath: "assets/images/Chicken.png",
    categoryName: "Chicken"
  ),
  Category(
    numberOfItems: 23,
    imagePath: "assets/images/veg.png",
    categoryName: "Vegitable"
  ),
];
1 Answers

Add Assets path in pubspec.yaml

assets:
    - assets/images/

Use Like:

   Image.asset(
        catagories[0].imagePath, // Similar way index should be used
        height: 20,
    ),
Related