可以创建一个浮动操作按钮来打开更多浮动按钮,如果是,你能给我一个例子吗?
像这些 :
Flutter 提供了一个named parameter
in Scaffold Widget - 'floatingActionButton'。并且命名参数floatingActionButton
不应该只采用FloatingActionButton
小部件,它应该采用Widget
并且确实如此。因此,您可以分配另一个小部件而不是FloatingActionButton
like as Column, Row, Stack
。它有效。
floatingActionButton: Row(
children: [
RaisedButton(child: Text('Button1'), onPressed: (){}),
RaisedButton(child: Text('Button1'), onPressed: (){}),
]
),
我只是给你一个参考例子,它会起作用 - 你只需要根据需要自定义样式和定位。希望它会有所帮助。
使用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,),
...
]
),
尝试这个
floatingActionButton: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
FloatingActionButton(
onPressed: getImage,
child: Icon(Icons.camera),
),
SizedBox(height: 8,),
FloatingActionButton(
onPressed: getImage,
child: Icon(Icons.camera),
),
],
)