其他分享
首页 > 其他分享> > flutter自定义floatingActionButton的位置

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

标签:自定义,offsetX,offset,floatingActionButton,offsetY,location,Offset,FloatingActionBu
来源: https://blog.csdn.net/Mytechnologe_2417/article/details/104823456