7

可以创建一个浮动操作按钮来打开更多浮动按钮,如果是,你能给我一个例子吗?

像这些 :

FloatActionButton padrão

múltiplos botões flutuantes

4

3 回答 3

12

Flutter 提供了一个named parameterin Scaffold Widget - 'floatingActionButton'。并且命名参数floatingActionButton不应该只采用FloatingActionButton小部件,它应该采用Widget并且确实如此。因此,您可以分配另一个小部件而不是FloatingActionButtonlike as Column, Row, Stack。它有效。

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

我只是给你一个参考例子,它会起作用 - 你只需要根据需要自定义样式和定位。希望它会有所帮助。

于 2019-11-03T03:24:53.083 回答
2

使用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,),
        ...
 ]
),
于 2020-02-01T08:06:47.287 回答
1

尝试这个

floatingActionButton: Column(
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            FloatingActionButton(
              onPressed: getImage,
              child: Icon(Icons.camera),
            ),
            SizedBox(height: 8,),
            FloatingActionButton(
              onPressed: getImage,
              child: Icon(Icons.camera),
            ),
          ],
        )
于 2021-06-03T14:44:56.647 回答