Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Multiple Floating button in Stack Widget in Flutter

In flutter one view over another view using Stack Widget. It's work fine. Now I need to added two floating button left and right side of bottom of screen. I added one button right side but I dnt know how to add floating button left side. Simple like below image.

enter image description here

Any help will appreciable

like image 713
Magesh Pandian Avatar asked Aug 30 '25 15:08

Magesh Pandian


2 Answers

You can use the Align widget to position your FloatingActionButton's in the Stack.

Stack(
  children: <Widget>[
    Align(
      alignment: Alignment.bottomLeft,
      child: FloatingActionButton(...),
    ),
    Align(
      alignment: Alignment.bottomRight,
      child: FloatingActionButton(...),
    ),
  ],
)

One button uses constant Alignment.bottomLeft for its alignment property and the other one respectively Alignment.bottomRight.

like image 190
creativecreatorormaybenot Avatar answered Sep 14 '25 07:09

creativecreatorormaybenot


You can also use something like this using location as centerDocked so that you don't get that weird left alignment.

floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: Padding(
  padding: const EdgeInsets.all(8.0),
  child: Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: <Widget>[
      FloatingActionButton(
        onPressed: () {},
        child: Icon(Icons.navigate_before),
      ),
      FloatingActionButton(
        onPressed: () {},
        child: Icon(Icons.navigate_next),
      )
    ],
  ),
)

Example result:

enter image description here

like image 40
Pawann Kumaarr Avatar answered Sep 14 '25 07:09

Pawann Kumaarr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!