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

Centering Floating Action Button in navigation bar Flutter

I have created a navigation bar in flutter, now I want to add a button in between the navbar icons as shown in this image.
I want this

But I am getting this. I am getting this

I brought the button in the middle with following code:

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

floatingActionButton: FloatingActionButton(
  onPressed: () {},
  child: const Icon(PhosphorIcons.plusLight,color: navBarColor),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,

Is there any way to bring it in the middle of the navbar?

If there is a there is a way to give circle background color to a navbar destination, then it would be better.

>Solution :

Try adding an alignment to the fab

floatingActionButtonLocation:
              FloatingActionButtonLocation.centerDocked,
          floatingActionButton: Align(
            alignment: Alignment.bottomCenter,
            child: Container(
              padding: const EdgeInsets.only(bottom: 6.0),
              
              child:  FloatingActionButton(
                onPressed: () {},
               
                child: Icon(Icons.add),
              ),
            ),
          ),
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