EN VI

how remove innerpadding of textbutton flutter?

2024-03-16 03:30:10
how remove innerpadding of textbutton flutter?

How to remove internal spacing from a text button in flutter?

enter image description here

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),
                  ))),

Solution:

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 :

minimumSize: MaterialStatePropertyAll(Size(50,50)),

note: keep padding set to zero

Hope it helps you.

Answer

Login


Forgot Your Password?

Create Account


Lost your password? Please enter your email address. You will receive a link to create a new password.

Reset Password

Back to login