Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to remove default padding in OutlinedButton?

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;

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

OutlinedButton

I want the paddings at the left and right removed, so I can customize to my preference. Thanks.

>Solution :

Just add minimumSize: Size.zero,padding: EdgeInsets.zero, in OutlinedButton.styleFrom()

 SizedBox(
        width: 150.0,
        height:100,    
        child: OutlinedButton(
          onPressed: () {
            
          },
          style: OutlinedButton.styleFrom(
            minimumSize: Size.zero, 
           padding: EdgeInsets.zero,
            backgroundColor: Colors.yellow,
            shape: const RoundedRectangleBorder(
              borderRadius: BorderRadius.only(
                topLeft: Radius.circular(20),
                topRight: Radius.circular(30),
                bottomLeft: Radius.circular(20),
                bottomRight: Radius.circular(20),
              ),
            ),
          ),
          child: Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Column(
                
                children: [
                  Text("duration"),
                  Text("dataPlan"),
                  Text("price"),
                ],
              ),
            ],
          ),
        )),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading