Flutter image doesn't appear on screen

════════ Exception caught by image resource service ════════════════════════════
Unable to load asset: cocacola_bottle.jpg.

This is the yaml file:

    - assets/

This is the page:

 class Signup extends StatelessWidget {
  const Signup({super.key});

  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        margin: EdgeInsets.all(8.0),
        child: Row(
          // first row first box
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
              width: MediaQuery.of(context).size.width / 2,
              height: 1040,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(20.0),
                image: DecorationImage(
                  fit: BoxFit.contain,
                  image: AssetImage('cocacola_bottle.jpg'),

However, image the doesn’t appear on screen.

>Solution :

You have to pass the full path:

image: AssetImage('assets/cocacola_bottle.jpg'),

Leave a Reply