多个浮动按钮-颤振

时间:2019-11-03 03:02:54

标签: flutter flutter-layout

可以创建一个浮动操作按钮来打开更多的浮动按钮,如果可以,请举个例子吗?

喜欢这些:

FloatActionButton padrão

múltiplos botões flutuantes

3 个答案:

答案 0 :(得分:1)

Flutter在脚手架小部件-“ floatingActionButton”中给出了named parameter。而且,命名参数floatingActionButton不应仅使用FloatingActionButton小部件,而应采用Widget,并且确实需要。因此,您可以像FloatingActionButton一样分配另一个小部件而不是Column, Row, Stack。而且有效。

floatingActionButton: Row(
  children: [
    RaisedButton(child: Text('Button1'), onPressed: (){}),
    RaisedButton(child: Text('Button1'), onPressed: (){}),
  ]
),

我只给您一个参考示例,它将起作用-您只需要根据需要自定义样式和位置。希望对您有所帮助。

答案 1 :(得分:0)

使用flutter_speed_dial软件包提供的SpeedDial小部件,您可以将多个浮动按钮用作父浮动操作按钮的子按钮。您还可以添加动画图标。

在pubspec.yaml中的依赖项下,添加:

dependencies:
 flutter_speed_dial: ^1.2.5

现在,您可以在FAB中使用SpeedDial小部件:

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,),
        ...
 ]
),

答案 2 :(得分:0)

试试这个

floatingActionButton: Column(
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            FloatingActionButton(
              onPressed: getImage,
              child: Icon(Icons.camera),
            ),
            SizedBox(height: 8,),
            FloatingActionButton(
              onPressed: getImage,
              child: Icon(Icons.camera),
            ),
          ],
        )