专栏更改 FAB 在 flutter 中的位置

Column changes FAB's position in flutter

我有一个问题,如果我将我的 FAB 放在列中 BottomNavigationBar 的末尾,它会改变它们的位置。我不想将它包装在一个堆栈中,因为它不可点击,我尝试了各种方法来解决这个问题,但是 none 的方法有效。

FAB 1:

Widget add(){
   return new FloatingActionButton(
    onPressed: (){Navigator.push(context, new MaterialPageRoute(builder: (context) => HomePage()));},
    heroTag: 'btnAdd',
    child: new Icon(Icons.add),
    backgroundColor: Colors.blue,
    elevation: 0.0,
    splashColor: Colors.redAccent,
  );
}

FAB 2:

  Widget floatMain(){
    return new FloatingActionButton(
      heroTag: 'btnMain',
      child: new AnimatedIcon(
        icon: AnimatedIcons.menu_close,
        progress: _animateIcon,
      ),
      tooltip: 'floatMain',
      onPressed: animate,
      backgroundColor: _buttonColor.value,
   );
 }

FAB 电话:

floatingActionButton: new Container(
    child: new Stack(
      children: <Widget>[
        new Container(
          child: new Transform(
            transform: Matrix4.translationValues(0.0, _translateButton.value - 56, 0.0),
            child: add(),
          ),
        ),
        floatMain(),
      ],
    ),
  ),
  floatingActionButtonLocation: FloatingActionButtonLocation.endDocked

所以,如果我将它包装在堆栈中,它可以工作,但它不适用于列。

如果只需要FAB按钮右下对齐。内栏 试试吧。

Expanded(
 child: Align(
alignment:FractionalOffset.bottomRight,
child: Padding(
 padding: EdgeInsets.only(bottom: 10.0), 
child: floatMain()//Your FAB widget here,
 ), 
), 
),