简体   繁体   English

Flutter Floating Action Button位置问题

[英]Flutter Floating Action Button location problem

I have added a floating action button in the bottomNavigationBar.我在底部导航栏中添加了一个浮动操作按钮。 The default location should be on the bottom right, but mine stays at the center.默认位置应该在右下角,但我的位置在中心。

I have tried using this floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, but the FAB still resides at the center screen.我曾尝试使用这个floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,但 FAB 仍位于中心屏幕。

Here is my full code of the screen:这是我的屏幕完整代码:

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,
);
}

Any idea how to solve this?知道如何解决这个问题吗?

Replace:代替:

bottomNavigationBar: FloatingActionButton(...)

with:和:

floatingActionButton: FloatingActionButton(...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM