【问题标题】:Centering the extended FAB使扩展的 FAB 居中
【发布时间】:2018-10-23 03:51:00
【问题描述】:

您如何将 Flutter 中提供的扩展 FAB 与 Material design 规范一样居中?

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

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

【问题讨论】:

    标签: dart flutter


    【解决方案1】:

    您需要做的就是在Scaffold 上设置floatingActionButtonLocation 属性

    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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-02
      • 1970-01-01
      • 1970-01-01
      • 2023-02-08
      • 2018-10-25
      • 1970-01-01
      • 2012-04-10
      • 1970-01-01
      相关资源
      最近更新 更多