Mirana
Mirana

Reputation: 37

Add a button with a size and add icon inside it in flutter

I am trying to add an icon to a button. What steps I followed: Created an icon button filled in the properties. After this, I wrapped it in a container because I don't want my button to be big. Here is the image of what I am getting: [![enter image description here][1]][1]

I want that Icon to be fit inside the button,I even tried to wrap the child with centre but still the same results.

My Code Snippet: Container( height:18, width:20, decoration:BoxDecoration( border:Border.all(color:Colors.orangeAccent,width:1), shape:BoxShape.rectangle, ), child:Centre(child:IconButton( icon:Icon(Icons.add, size:16, color:Colors.orange,), onPressed:(){}, ),),

Upvotes: 0

Views: 671

Answers (3)

Furkan Cetintas
Furkan Cetintas

Reputation: 822

You can try this code block

Container(
  width: 50,
  height: 50,
  child: FlatButton(
    onPressed: () {},
    child: Row(
      children: [
        Icon(Icons.ac_unit),
        Text('Add More')
      ],
    ),
  ),
)

Upvotes: 2

Salim Murshed
Salim Murshed

Reputation: 1451

The easiest way you can do like below code.

Container(
    width: 50,
    height: 50,
    child: GestureDetector(
      onTap: () {},
      child: Row(
        children: [
          Icon(Icons.ac_unit),
          Padding(
            padding:  EdgeInsets.only(left: 10),
            child: Text('Add More'),
          )
        ],
      ),
    ),
  )

Upvotes: 1

sungkd123
sungkd123

Reputation: 403

You can use TextIconButton instead of IconButton.

Upvotes: 0

Related Questions