Search code examples
flutterflutter-layout

Multiple floating buttons - Flutter


it's possible to create a float action button which open more float buttons, and If yes, can you give me a example?

Like these :

FloatActionButton padrão

múltiplos botões flutuantes


Solution

  • Flutter gives a named parameter in Scaffold Widget - ‘floatingActionButton’. And the named parameter floatingActionButton shouldn't take only FloatingActionButton widget, it should take Widget and it does. So you can assign another widget instead of FloatingActionButton like as Column, Row, Stack. And it works.

    floatingActionButton: SingleChildScrollView(
      child: Row(
        children: [
          RaisedButton(child: Text('Button1'), onPressed: (){}),
          const SizedBox(height: 10, width: 0),
          RaisedButton(child: Text('Button1'), onPressed: (){}),
       ],
      ),
    ),
    

    I just give you a reference example, it will work - you just need to customize the styles and positioning as you want. Hope it will be helpful.