使扩展FAB居中

时间:2018-05-13 08:23:03

标签: dart flutter

Extended FAB

如何将Flutter中提供的扩展FAB集中在材料设计规范中?

这里扩展的FAB是右对齐的:

new Scaffold(
    floatingActionButton: new FloatingActionButton.extended(
        onTap: () => {},
        label: new Text('See all results')
    }
)

1 个答案:

答案 0 :(得分:3)

您需要做的就是在floatingActionButtonLocation

上设置Scaffhold
class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: ...       
      body: ...
      floatingActionButton: MyFloatingActionButton(),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat
    );
  }

class MyFloatingActionButton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return FloatingActionButton.extended(
          icon: Icon(Icons.plus_one),
          onPressed: () => {},
          label: new Text('See all results'));
  }
}

请注意,这是问题的重复:Flutter - FloatingActionButton in the center

相关问题