How to create rectangle icon button without label in flutter?

3,614

Solution 1

Container(
  height: 100.0,
  width: 100.0,
  child: FlatButton(
    child: Icon(Icons.place),
    onPressed: () {},
  ),
),

Solution 2

You can create a container with an icon as a child and wrap the container with the InkWell widget to make it clickable. This way you can shape your container to your need, which in this case is a rectangle.

Here's a code sample -

InkWell(
        child: Container(
          decoration: BoxDecoration(
              shape: BoxShape.rectangle,
              border: Border.all(
                width: 1,
              )),
          child: Icon(Icons.add, color: Colors.black),
        ),
        onTap: () {},
      ),
Share:
3,614
rahul  Kushwaha
Author by

rahul Kushwaha

Updated on December 15, 2022

Comments

  • rahul  Kushwaha
    rahul Kushwaha over 1 year

    we can create the icon button with FlatButton.icon() but it requires label parameter. we can also use IconButton() but it makes a circular icon button.

    how to make a rectangle icon button like FlatButton() but with just icon in flutter?