How to change the Flutter TextButton height?

Solution 1:

You just wrap your text button with the SizedBox and set height and width as follows:

SizedBox(
  height: 30,
  width: 150,
  child: TextButton(...),
)

Solution 2:

  • Full available height:

    SizedBox(
      height: double.infinity, // <-- match_parent
      child: TextButton(...)
    )
    
  • Specific height:

    SizedBox(
      height: 100, // <-- Your height
      child: TextButton(...)
    )
    

Solution 3:

In Flutter 2.0, you can set the height of the TextButton directly without depending on other widgets by changing the ButtonStyle.fizedSize:

TextButton(
  child: Text('Text Button'),
  style: TextButton.styleFrom(fixedSize: Size.fromHeight(150)),
),

If you want to modify all TextButtons, put it in the ThemeData like below:

return MaterialApp(
  theme: ThemeData(
    textButtonTheme: TextButtonThemeData(
      style: TextButton.styleFrom(fixedSize: Size.fromHeight(150)),
    ),
  ),

Live Demo

Solution 4:

use the following to even add your preferred size as well

N/B: child sized box is the main child widget inside Padding widget

Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Padding(
                      padding: const EdgeInsets.all(30.0),
                      child: SizedBox(
                        height: 60,
                        width: 200,
                        child: ElevatedButton.icon(
                          onPressed: () {
                            Navigator.push(
                                context,
                                MaterialPageRoute(
                                    builder: (context) => RegistrationMenu()));
                          },
                          style: ButtonStyle(
                            backgroundColor:
                                MaterialStateProperty.all(Colors.red.shade800),
                          ),
                          icon: Icon(Icons.person_add_alt_1_rounded, size: 18),
                          label: Text("Register Users"),
                        ),
                      ),
                    ),
                  ],
                ),

Solution 5:

Another solution would be wrapping with ConstrainedBox and using minWidth & minHeight

properties.


ConstrainedBox(
  constraints:BoxConstraints(
    minHeight:80,
    minWidth:200
    ),
  child:TextButton(..)
)