flutter自定义floatingActionButton的位置

class CustomFloatingActionButtonLocation extends FloatingActionButtonLocation {
  FloatingActionButtonLocation location;
  double offsetX;    // X方向的偏移量
  double offsetY;    // Y方向的偏移量
  CustomFloatingActionButtonLocation(this.location, this.offsetX, this.offsetY);

  @override
  Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) {
    Offset offset = location.getOffset(scaffoldGeometry);
    return Offset(offset.dx + offsetX, offset.dy + offsetY);
  }
}
floatingActionButton: FloatingActionButton(
  child: Icon(Icons.add,color: Colors.white),
  onPressed: (){
    print('FloatingActionButton');
  },
),
floatingActionButtonLocation: CustomFloatingActionButtonLocation(FloatingActionButtonLocation.centerFloat, 0, -56),
上一篇:js拖拽效果的原理及多种实现方法


下一篇:仿抖音右滑清屏,左滑列表功能