6

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?

rahul Kushwaha
  • 2,395
  • 7
  • 32
  • 64

3 Answers3

5
Container(
  height: 100.0,
  width: 100.0,
  child: FlatButton(
    child: Icon(Icons.place),
    onPressed: () {},
  ),
),
Stellar Creed
  • 384
  • 5
  • 14
  • I see no rectangle button there, it just shows a (pretty big) rectangle when you clock on it. – Gigili Jul 01 '21 at 10:50
1

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: () {},
      ),
Abbas
  • 773
  • 6
  • 16
0

Using Inkwell combination with container you can make customized button easily as done in above example

InkWell(
        child: Container(
          decoration: BoxDecoration(
              shape: BoxShape.rectangle,
              border: Border.all(
                width: 1,
              )),
          child: Icon(Icons.add, color: Colors.black),
        ),
        onTap: () {},
      ),
IonicFireBaseApp
  • 925
  • 3
  • 10