Oscar Raphy
Oscar Raphy

Reputation: 1

My decoration image is not showing in flutter

Card(
                      child: Container(
                      height: 250,
                      width: 180,
                        //color: Colors.pink,
                        child: Column(
                          children: <Widget>[
                            Container(
                              height: 190,
                              width: 160,
                              decoration: BoxDecoration(
                                 // color:Colors.white,
                                image: DecorationImage(
                                  image:AssetImage("assets/images/hamlogo.png"),),
                              ),
                            ),
                            Text("\AED 30.00",style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),),
                          ],
                        ),
                    ),),

pubspec

flutter:

The following line ensures that the Material Icons font is

included with your application, so that you can use the icons in

the material Icons class.

uses-material-design: true

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

assets:

Upvotes: 0

Views: 838

Answers (1)

eamirho3ein
eamirho3ein

Reputation: 17890

I think you are not setting asset correctly, follow this:

first you need create a asset folder in your project root folder, like this:

enter image description here

then in your pubspec.yaml , under flutter: define it like this:

assets:
    - assets/images/

enter image description here

then run flutter pub get now if you call image, you can see it:

Card(
        child: Container(
          height: 250,
          width: 180,
          //color: Colors.pink,
          child: Column(
            children: <Widget>[
              Container(
                height: 190,
                width: 160,
                decoration: BoxDecoration(
                  // color:Colors.white,
                  image: DecorationImage(
                    image: AssetImage('assets/images/test.jpeg'),
                  ),
                ),
              ),
              Text(
                "\AED 30.00",
                style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
              ),
            ],
          ),
        ),
      ),

enter image description here

Note: if you still not getting image, please stop project and close ide, then open it again run flutter pub get then run then project.

Upvotes: 0

Related Questions