Floating constructor
Floating(
- Widget child, {
- FloatingSlideType slideType = FloatingSlideType.onRightAndBottom,
- double? top,
- double? left,
- double? right,
- double? bottom,
- Point<
double> ? point, - double moveOpacity = 0.3,
- bool isPosCache = true,
- bool isShowLog = true,
- bool isSnapToEdge = true,
- bool isStartScroll = true,
- double slideTopHeight = 0,
- double slideBottomHeight = 0,
- double snapToEdgeSpace = 0,
- SlideStopType slideStopType = SlideStopType.slideStopAutoType,
child
需要悬浮的 widget
slideType
,悬浮窗坐标的起始点位置,可参考FloatingSlideType
top
,left
,left
,bottom
,point
对应 slideType
,设置与起始点的距离
例如设置slideType
为FloatingSlideType.onRightAndBottom,则需要传入bottom
和right
设置 slideType
为 FloatingSlideType.onPoint 则需要传入 point
isPosCache
是否在调用 Floating.open 时,保持上一次 Floating.close 前的位置
isSnapToEdge
是否自动吸附左右边缘,默认为 true
请注意,移动默认是有透明动画的,如需要关闭透明度动画,请修改 moveOpacity
为 1
isStartScroll
是否允许拖动悬浮窗,默认为 true
slideTopHeight
拖动范围限制,与顶部的最小距离(可设为负数)
slideBottomHeight
拖动范围限制,与底部的最小距离(可设为负数)
snapToEdgeSpace
吸附后回弹至与边缘的距离,不开启吸附则用于范围限制(可设为负数)
slideStopType
拖动后吸附在哪一侧
Implementation
Floating(
Widget child, {
FloatingSlideType slideType = FloatingSlideType.onRightAndBottom,
double? top,
double? left,
double? right,
double? bottom,
Point<double>? point,
double moveOpacity = 0.3,
bool isPosCache = true,
bool isShowLog = true,
bool isSnapToEdge = true,
bool isStartScroll = true,
double slideTopHeight = 0,
double slideBottomHeight = 0,
double snapToEdgeSpace = 0,
SlideStopType slideStopType = SlideStopType.slideStopAutoType,
}) {
_floatingData = FloatingData(slideType,
left: left,
right: right,
top: top,
bottom: bottom,
point: point,
snapToEdgeSpace: snapToEdgeSpace);
_log = FloatingLog(isShowLog);
_commonControl = CommonControl();
_commonControl.setInitIsScroll(isStartScroll);
_scrollPositionControl = ScrollPositionControl();
_scrollPositionManager = ScrollPositionManager(_scrollPositionControl);
_floatingView = FloatingView(
child,
_floatingData,
isPosCache,
isSnapToEdge,
_listener,
_scrollPositionControl,
_commonControl,
_log,
moveOpacity: moveOpacity,
slideTopHeight: slideTopHeight,
slideBottomHeight: slideBottomHeight,
slideStopType: slideStopType,
);
}