0

I want to add an icon to a card widget so I used the ImageIcon widget as below

Card(
  color: colorPalette.cultured,
  child: Padding(
    padding: const EdgeInsets.all(20.0),
    child: Row(
      children: <Widget>[
        Text(label,style: TextStyle(fontWeight: FontWeight.w600,fontSize: 15.0,fontFamily: 'Poppins'),),
        Spacer(),
        ImageIcon(AssetImage('assets/icons/call.png'),),
      ],
    ),
  ),
);

The icon I want to display is,

call.png

but what is displayed is,

enter image description here

the assets in the pubspec.yaml are indented properly as well.

James Z
  • 12,209
  • 10
  • 24
  • 44
Kavishka Rajapakshe
  • 537
  • 1
  • 8
  • 23

2 Answers2

0

You can use either of these for using asset images
Image.asset('image')
or
Image(image: AssetImage('image')) for using asset images

For achieving it with icon

Container(
            width: 40,
            height: 40,
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(10),
                color: Colors.blue),
            child: Icon(
              Icons.call,
              color: Colors.white,
            ),
          )

enter image description here

mohit yadav
  • 166
  • 4
0

Try below Code Hope its help to you . Just change your image on your need

you have add asset image in 2 Ways

  1. Image.assets() - Documentation here
  1. AssetImage()
      Row(
             children: [
               Image(
                  image: AssetImage('assets/images/shop.png'),
                  width: 150,
                  height: 150,
                ),
                Image.asset(
                  'assets/images/cycle.png',
                  width: 150,
                  height: 150,
                ),
             ],
           ),

Your Result Screen -> enter image description here

Ravindra S. Patil
  • 11,757
  • 3
  • 13
  • 40