Flutter TextButton
is the new button. Since Flutter 2.0 FlatButton is deprecated.
Example of how to use this button with custom styles.
This is a back button with an icon.
It has a wide pressable area and alignment to left according to design.
For inner padding just use Padding
widget in the child property – it gives you consistent style for any String length.
TextButton(
onPressed: () => Navigator.pop(context),
style: TextButton.styleFrom(
padding: EdgeInsets.zero,
minimumSize: Size(50, 30),
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
alignment: Alignment.centerLeft),
child: Icon(
CupertinoIcons.back,
color: Colors.black,
size: 18,
),
),
For those who are curious about tapTargetSize: MaterialTapTargetSize.shrinkWrap,
property – more info is here https://stackoverflow.com/a/71841707/7198006