RefreshPhysics class
用于配置下拉刷新和上拉加载的滚动物理效果
该类扩展了Flutter的ScrollPhysics,主要用于:
- 允许视口超出边缘滚动,无论父级物理效果是什么
- 处理刷新过程中的滚动拦截
- 处理二级刷新打开和关闭时的滚动
- 支持自定义弹簧回弹动画
- 适配iOS和Android不同的滚动效果
可以通过RefreshConfiguration设置更多参数
示例用法:
SmartRefresher(
physics: RefreshPhysics(
maxOverScrollExtent: 100.0,
springDescription: SpringDescription(
stiffness: 170.0,
damping: 16.0,
mass: 1.0,
),
),
controller: _refreshController,
onRefresh: _onRefresh,
child: ListView.builder(
itemCount: 20,
itemBuilder: (context, index) => ListTile(title: Text("Item $index")),
),
);
参考:
- RefreshConfiguration - 控制SmartRefresher组件在子树中的行为
- Inheritance
-
- Object
- ScrollPhysics
- RefreshPhysics
Constructors
- RefreshPhysics({ScrollPhysics? parent, int? updateFlag, double? maxUnderScrollExtent, SpringDescription? springDescription, RefreshController? controller, double? dragSpeedRatio, double? topHitBoundary, double? bottomHitBoundary, bool? enableScrollWhenRefreshCompleted, double? maxOverScrollExtent})
- 创建滚动物理效果,用于控制下拉刷新和上拉加载的行为
Properties
- allowImplicitScrolling → bool
-
Whether a viewport is allowed to change its scroll position implicitly in
response to a call to RenderObject.showOnScreen.
no setterinherited
- allowUserScrolling → bool
-
Whether a viewport is allowed to change the scroll position as the result of user input.
no setterinherited
- bottomHitBoundary → double?
-
底部碰撞边界
final
- controller → RefreshController?
-
刷新控制器
final
- dragSpeedRatio → double?
-
拖动速度比例
final
- dragStartDistanceMotionThreshold → double?
-
The minimum amount of pixel distance drags must move by to start motion
the first time or after each time the drag motion stopped.
no setterinherited
- enableScrollWhenRefreshCompleted → bool?
-
刷新完成后是否允许滚动
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxFlingVelocity → double
-
Scroll fling velocity magnitudes will be clamped to this value.
no setterinherited
- maxOverScrollExtent → double?
-
最大上拉超出范围
final
- maxUnderScrollExtent → double?
-
最大下拉超出范围
final
- minFlingDistance → double
-
The minimum distance an input pointer drag must have moved to be
considered a scroll fling gesture.
no setterinherited
- minFlingVelocity → double
-
The minimum velocity for an input pointer drag to be considered a
scroll fling.
no setterinherited
- parent → ScrollPhysics?
-
If non-null, determines the default behavior for each method.
finalinherited
- runtimeType → Type
-
获取运行时类型
no setteroverride
- spring → SpringDescription
-
The spring to use for ballistic simulations.
no setterinherited
- springDescription → SpringDescription?
-
弹簧动画描述
final
- tolerance → Tolerance
-
Deprecated. Call toleranceFor instead.
no setterinherited
- topHitBoundary → double?
-
顶部碰撞边界
final
- updateFlag → int?
-
更新标志,用于控制运行时类型
final
- viewportRender ↔ RenderViewport?
-
视口渲染对象
getter/setter pair
Methods
-
adjustPositionForNewDimensions(
{required ScrollMetrics oldPosition, required ScrollMetrics newPosition, required bool isScrolling, required double velocity}) → double -
Describes what the scroll position should be given new viewport dimensions.
inherited
-
applyBoundaryConditions(
ScrollMetrics position, double value) → double -
应用边界条件到滚动位置
override
-
applyPhysicsToUserOffset(
ScrollMetrics position, double offset) → double -
将物理效果应用到用户拖动偏移上
override
-
applyTo(
ScrollPhysics? ancestor) → RefreshPhysics -
创建一个新的滚动物理效果,将当前物理效果应用到父级物理效果上
override
-
buildParent(
ScrollPhysics? ancestor) → ScrollPhysics? -
If parent is null then return ancestor, otherwise recursively build a
ScrollPhysics that has
ancestoras its parent.inherited -
carriedMomentum(
double existingVelocity) → double -
Returns the velocity carried on repeated flings.
inherited
-
createBallisticSimulation(
ScrollMetrics position, double velocity) → Simulation? -
创建弹道滚动模拟
override
-
findViewport(
BuildContext? context) → RenderViewport? - 查找视口渲染对象
-
frictionFactor(
double overscrollFraction) → double - 计算摩擦系数
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
recommendDeferredLoading(
double velocity, ScrollMetrics metrics, BuildContext context) → bool -
Provides a heuristic to determine if expensive frame-bound tasks should be
deferred.
inherited
-
shouldAcceptUserOffset(
ScrollMetrics position) → bool -
决定是否接受用户的拖动偏移
override
-
toleranceFor(
ScrollMetrics metrics) → Tolerance -
The tolerance to use for ballistic simulations.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited