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: () {},
),
Author by
rahul Kushwaha
Updated on December 15, 2022Comments
-
rahul Kushwaha over 1 year
we can create the icon button with
FlatButton.icon()
but it requireslabel
parameter. we can also useIconButton()
but it makes a circular icon button.how to make a rectangle icon button like
FlatButton()
but with just icon in flutter?