0

File where I want to load image

class _HomeState extends State<Home> {
      @override
      Widget build(BuildContext context) {
        return Container(
          height: 250,
          child: Card(
            child: Image.asset(
              '../../assets/images/person.jpg',
              fit: BoxFit.cover,
            ),
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(10.0),
            ),
            elevation: 5,
            margin: EdgeInsets.all(10),
          ),
        );
      }
    }

pubspec.yaml

 # To add assets to your application, add an assets section, like this:
 assets:
  - assets/images/person.jpg
  - assets/images/burger.jpg

I have used flutter clean command also, i get image for once then after adding more images my project stuck. Unable to solve this problem. This is happening for Suggestion would be appreciated?

Shrey Jain
  • 73
  • 1
  • 5

1 Answers1

1

Bro you define wrong Image paths in pubspec.yaml file

define this way :

 assets:
   - assets/images/

for more info try out

this

or

this

and In your .dart file define this way :

Image.asset('assets/images/person.jpg'),
Aamil Silawat
  • 7,735
  • 3
  • 19
  • 37