1 ScrollableState._handleDragUpdate
2 _drag.update() _drag 的类型为 ScrollDragController
3 delegate.applyUserOffset() delegate 的类型为 ScrollPositionWithSingleContext(继承了ScrollPosition)
4 setPixels 在调用这个方法的时候调用了 ScrollPhysics.applyPhysicsToUserOffset
ScrollPhysics.applyPhysicsToUserOffset 的默认实现
参数 第二个参数是用户实际手指滑动的距离
所以 pixels - physics.applyPhysicsToUserOffset(this, delta) 计算结果就是在已有的偏移量上加上applyPhysicsToUserOffset计算出的结果,ScrollPhysics.applyPhysicsToUserOffset的默认实现是返回Offset也就是用户的偏移量。
ScrollPositionWithSingleContext.setPixels 的实现
直接调用父类(ScrollPosition)的setPixels,实现如下
在这里调用了applyBoundaryConditions。方法实现
调用了physics的applyBoundaryConditions,并将结果返回。
ScrollPhysics.applyBoundaryConditions 的默认实现是直接返回0