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 align a text to center bottom of a IconButton widget?

I want to align a text to the center bottom of the IconButton but it’s not in the center instead it at the start.

Example of what i wanted : Image Here

The thing that it show: Image here

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

The Code

Column(
              children: [
                Row(
                  mainAxisAlignment:
                      MainAxisAlignment
                          .spaceBetween,
                  children: [
                    IconButton(
                        onPressed: () {},
                        icon: Icon(
                          Icons.library_add_check,
                          size: 22,
                        )),
                    IconButton(
                        onPressed: () {},
                        icon: Icon(
                          Icons.message,
                          size: 22,
                        )),
                    IconButton(
                        onPressed: () {},
                        icon: Icon(
                          Icons.thumb_up,
                          size: 22,
                        )),
                    IconButton(
                        onPressed: () {},
                        icon: Icon(
                          Icons.supervisor_account,
                          size: 22,
                        )),
                  ],
                ),
                Row(
                  mainAxisAlignment:
                      MainAxisAlignment
                          .spaceBetween,
                  children: [
                    Align(
                        alignment: Alignment.center,
                        child: Text(
                          "All",
                        )),
                  ],
                ),
                
              ],
            ),

I have tried everything i know but it still doesn’t work.
Thanks alot if you can help me with this issue.

>Solution :

Instead of creating another row for your IconButton() text wrap your IconButton() with Column() and add Text() to that Column().

You can do something like this.

Column(
          children: [
            Row(
              mainAxisAlignment:
                  MainAxisAlignment
                      .spaceEvenly,
              children: [
                Column(
                  children:[
                    IconButton(
                    onPressed: () {},
                    icon: Icon(
                      Icons.library_add_check,
                      size: 22,
                    )),
                    Text("abc"),
                  ],
                ),
                Column(
                  children:[
                    IconButton(
                    onPressed: () {},
                    icon: Icon(
                      Icons.thumb_up,
                      size: 22,
                    )),
                    Text("abc"),
                  ],
                ),
                Column(
                  children:[
                    IconButton(
                    onPressed: () {},
                    icon: Icon(
                      Icons.message,
                      size: 22,
                    )),
                    Text("abc"),
                  ],
                ),
                Column(
                  children:[
                    IconButton(
                    onPressed: () {},
                    icon: Icon(
                      Icons.supervisor_account,
                      size: 22,
                    )),
                    Text("ABC"),
                  ],
                ),
              ],
            ),
          ],
        );

You can try it here

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