I want to remove the default padding from an outlined button. This is my code;
SizedBox(
width: 150.0,
child: OutlinedButton(
onPressed: () {
setState(() {
selected = index;
});
},
style: OutlinedButton.styleFrom(
backgroundColor: (selected == index) ? color : Colors.white,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(30),
bottomLeft: Radius.circular(20),
bottomRight: Radius.circular(20),
),
),
),
child: Row(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(duration),
Text(dataPlan),
Text(price),
],
),
],
),
),
);
The SizedBox is wrapped in a ListView.
This is the result I get;
I want the paddings at the left and right removed, so I can customize to my preference. Thanks.
3
Answers
Add in
Column
this property to reduce size of the widget.Add the following properties to the button style:
In addition, set the mainAxisSize on the Column and on the row to min:
Just add
minimumSize: Size.zero,padding: EdgeInsets.zero,
inOutlinedButton.styleFrom()