Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 503
Rebelss Avatar asked Nov 03 '19 03:11

Rebelss


3 Answers

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: Row(
  children: [
    RaisedButton(child: Text('Button1'), onPressed: (){}),
    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.

like image 67
Robin Avatar answered Nov 15 '22 10:11

Robin


Using the SpeedDial widget provided by flutter_speed_dial package you can use multiple float button as children of a parent floating action button. You can also add animated icons.

In your pubspec.yaml under dependecies, add:

dependencies:
 flutter_speed_dial: ^1.2.5

Now you can use the SpeedDial widget in your FAB:

floatingActionButton: SpeedDial(

//provide here features of your parent FAB

children: [
        SpeedDialChild(
          child: Icon(Icons.accessibility),
          label: 'First',
          onTap: null,),
        SpeedDialChild(
          child: Icon(Icons.accessibility),
          label: 'Second',
          onTap: null,),
        ...
 ]
),
like image 29
Bayard Avatar answered Nov 15 '22 11:11

Bayard


Try This

floatingActionButton: Column(
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            FloatingActionButton(
              onPressed: getImage,
              child: Icon(Icons.camera),
            ),
            SizedBox(height: 8,),
            FloatingActionButton(
              onPressed: getImage,
              child: Icon(Icons.camera),
            ),
          ],
        )
like image 29
Shiru99 Avatar answered Nov 15 '22 11:11

Shiru99