浮动浮动按钮位置问题

问题描述 投票:0回答:1

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

任何想法如何解决这个问题?

flutter dart flutter-layout
1个回答
1
投票

替换:

bottomNavigationBar: FloatingActionButton(...)

with:

floatingActionButton: FloatingActionButton(...)
© www.soinside.com 2019 - 2024. All rights reserved.