Search code examples
flutterdartflutter-layout

How to remove padding from Icon?


I have OutlinedButton with Row inside it with Icons on left and right and text between them.

This is how it's looking enter image description here

and how it's implemented in code:

Container(
                        width: size.width * 0.4,
                        child: OutlinedButton(
                          onPressed: () {
                            
                          },
                          style: OutlinedButton.styleFrom(
                              side: BorderSide(
                                  color: Color(0xFF44A5FF)
                              )
                          ),
                          child: Container(
                            width: size.width * 0.4,
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Icon(Icons.star_outline, color: Color(0xFF44A5FF)),
                                Container(
                                  width: (size.width * 0.3) * 0.6,
                                  child: AutoSizeText(
                                    selectedValue!,
                                    style: TextStyle(
                                        color: Color(0xFF44A5FF),
                                        fontWeight: FontWeight.w400
                                    ),
                                    maxLines: 1,
                                    minFontSize: 8,
                                  ),
                                ),
                                Icon(
                                  Icons.keyboard_arrow_down_sharp,
                                  color: Color(0xFF44A5FF),
                                ),
                              ],
                            ),
                          ),
                        ),
                      ),

I want to set these icons closer to start and end of OutlinedButton and I don't know how to achieve that.


Solution

  • You can provide padding on style, it will reduce some padding

    style: OutlinedButton.styleFrom(
      side: BorderSide(
        color: Color(0xFF44A5FF),
      ),
      padding: EdgeInsets.zero,
    ),
    

    enter image description here

    IconData comes with some default hard-coded value.