Flutter浮动操作按钮位置问题

时间:2020-03-25 18:35:48

标签: flutter dart flutter-layout

我在bottomNavigationBar中添加了一个浮动动作按钮。默认位置应在右下角,但我的位置仍在中心。

我尝试使用此floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, 但FAB仍位于中间屏幕。

这是我在屏幕上的完整代码:

Widget build(BuildContext context) {
return Scaffold(
  appBar: PreferredSize(
    preferredSize: Size.fromHeight(55.0),
    child: CustomAppBar(title: 'Customers (2)',),
  ),
  drawer: Theme(
    data: Theme.of(context).copyWith(
        canvasColor: Colors.white
    ),
    child: MyDrawer(),
  ),
  body: Container(
    padding: EdgeInsets.all(15.0),
    decoration: BoxDecoration(color: Colors.white),
    child: SingleChildScrollView(
      child: Column(
        children: <Widget>[
          Row(
            children: <Widget>[
              FaIcon(FontAwesomeIcons.search, color: Colors.greenAccent,),
              SizedBox(width: 15.0,),
              Text("Search Customers"),
            ],
          ),
        ],
      ),
    ),
  ),
  bottomNavigationBar: FloatingActionButton(
    child: FaIcon(FontAwesomeIcons.plus),
    backgroundColor: Colors.greenAccent,
    foregroundColor: Colors.white,
    splashColor: Colors.black,
    onPressed: () {
    },
  ),
  floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
);
}

有什么办法解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

替换:

bottomNavigationBar: FloatingActionButton(...)

具有:

floatingActionButton: FloatingActionButton(...)