Search code examples
fluttercompiler-errorsflutter-image

Unable to load asset: packages in flutter


i want to add some image on my app, but when i add image asset, i cant load image from folder assets/images .when i start debugging its show an error like this

my images code its like this

Container(
             margin: EdgeInsets.only(top: 0),
             height: 250,
             color: kMainColor,
             child: Container(
               margin: EdgeInsets.only(top: 70),
               decoration: BoxDecoration(
                 image: DecorationImage(
                   image: AssetImage('assets/images/sawi1.jpg',
                       package: 'plantgo_alpha'),
                   fit: BoxFit.contain,
                 ),
               ),
             ),
           ),

and this my pubspec.yaml

flutter:
 uses-material-design: true
 assets:
  - assets/icons/
  - assets/images/

images path path

i try to fix with another question and answer in this forum but still error, i rly appreciate if somebody help me fix this


Solution

  • For first you don't need to specify package. For second you have only one space before "assets:" and list of asset folders, it requires TWO spaces

    enter image description here