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

flutter, how to align the cross ICON to center position?

SizedBox(
        width: 20,
        height: 20,
        child: FloatingActionButton(
          onPressed: null,
          child: Icon(Icons.add),
        ),
),

I want to size Button and also want to put the ICON to center position, but it aligns bottomright little bit… how can I do it? (button size should be 20×20)

my code result picture

my code result picture

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

>Solution :

Try to use Container instead of SizedBox and set Alignment.center, refer Align:

   Container(
            alignment: Alignment.center,
            width: 20,
            height: 20,
            child: FloatingActionButton(
              onPressed: null,
              child: Icon(
                Icons.add,
                size: 15,
              ),
            ),
          ),

Result- image

Other way:

     FloatingActionButton(
            onPressed: null,
            child: Icon(Icons.add),
          ),

Result-> image

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