How to remove internal spacing from a text button in flutter?
Remove the internal spacing of the button
TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
EdgeInsets.zero),
tapTargetSize: MaterialTapTargetSize.shrinkWrap
),
onPressed: () {},
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: const Color(0xffF6F6F7),
borderRadius: BorderRadius.circular(50)),
child: const Padding(
padding: EdgeInsets.all(12.0),
child: Icon(CupertinoIcons.search),
))),
2
Answers
Why are you trying to use a text button, It seems you are supposed to use an icon button here.
The text button itself shows no boundary (shows shadow only on hover), there you can set the padding to any value below 4 to reduce the gap. Although usually it’s not recommended to place anything that close to a button.
As long as the child has fixed size, you can remove padding through making the
TextButton
to be as big as its child:just set :
note: keep padding set to zero
Hope it helps you.