final
This commit is contained in:
@@ -11,17 +11,17 @@ import 'shop_scroll_coordinator.dart';
|
||||
class ShopScrollPosition extends ScrollPosition
|
||||
implements ScrollActivityDelegate {
|
||||
final ShopScrollCoordinator coordinator; // 协调器
|
||||
ScrollDragController _currentDrag;
|
||||
ScrollDragController? _currentDrag;
|
||||
double _heldPreviousVelocity = 0.0;
|
||||
|
||||
ShopScrollPosition(
|
||||
{@required ScrollPhysics physics,
|
||||
@required ScrollContext context,
|
||||
{required ScrollPhysics physics,
|
||||
required ScrollContext context,
|
||||
double initialPixels = 0.0,
|
||||
bool keepScrollOffset = true,
|
||||
ScrollPosition oldPosition,
|
||||
String debugLabel,
|
||||
@required this.coordinator})
|
||||
ScrollPosition? oldPosition,
|
||||
String? debugLabel,
|
||||
required this.coordinator})
|
||||
: super(
|
||||
physics: physics,
|
||||
context: context,
|
||||
@@ -40,7 +40,7 @@ class ShopScrollPosition extends ScrollPosition
|
||||
|
||||
@override
|
||||
double setPixels(double newPixels) {
|
||||
assert(activity.isScrolling);
|
||||
assert(activity!.isScrolling);
|
||||
return super.setPixels(newPixels);
|
||||
}
|
||||
|
||||
@@ -51,13 +51,13 @@ class ShopScrollPosition extends ScrollPosition
|
||||
goIdle();
|
||||
return;
|
||||
}
|
||||
activity.updateDelegate(this);
|
||||
activity!.updateDelegate(this);
|
||||
final ShopScrollPosition typedOther = other as ShopScrollPosition;
|
||||
_userScrollDirection = typedOther._userScrollDirection;
|
||||
assert(_currentDrag == null);
|
||||
if (typedOther._currentDrag != null) {
|
||||
_currentDrag = typedOther._currentDrag;
|
||||
_currentDrag.updateDelegate(this);
|
||||
_currentDrag?.updateDelegate(this);
|
||||
typedOther._currentDrag = null;
|
||||
}
|
||||
}
|
||||
@@ -131,14 +131,14 @@ class ShopScrollPosition extends ScrollPosition
|
||||
}
|
||||
|
||||
@override
|
||||
void beginActivity(ScrollActivity newActivity) {
|
||||
void beginActivity(ScrollActivity? newActivity) {
|
||||
_heldPreviousVelocity = 0.0;
|
||||
if (newActivity == null) return;
|
||||
assert(newActivity.delegate == this);
|
||||
super.beginActivity(newActivity);
|
||||
_currentDrag?.dispose();
|
||||
_currentDrag = null;
|
||||
if (!activity.isScrolling) updateUserScrollDirection(ScrollDirection.idle);
|
||||
if (!activity!.isScrolling) updateUserScrollDirection(ScrollDirection.idle);
|
||||
}
|
||||
|
||||
/// 将[用户滚动方向]设置为给定值。
|
||||
@@ -154,7 +154,7 @@ class ShopScrollPosition extends ScrollPosition
|
||||
|
||||
@override
|
||||
ScrollHoldController hold(VoidCallback holdCancelCallback) {
|
||||
final double previousVelocity = activity.velocity;
|
||||
final double previousVelocity = activity!.velocity;
|
||||
final HoldScrollActivity holdActivity =
|
||||
HoldScrollActivity(delegate: this, onHoldCanceled: holdCancelCallback);
|
||||
beginActivity(holdActivity);
|
||||
@@ -195,10 +195,10 @@ class ShopScrollPosition extends ScrollPosition
|
||||
if (coordinator.pageExpand == PageExpandState.Expanding) return;
|
||||
}
|
||||
assert(pixels != null);
|
||||
final Simulation simulation =
|
||||
final Simulation? simulation =
|
||||
physics.createBallisticSimulation(this, velocity);
|
||||
if (simulation != null) {
|
||||
beginActivity(BallisticScrollActivity(this, simulation, context.vsync));
|
||||
beginActivity(BallisticScrollActivity(this, simulation, context.vsync, true));
|
||||
} else {
|
||||
goIdle();
|
||||
}
|
||||
@@ -220,8 +220,8 @@ class ShopScrollPosition extends ScrollPosition
|
||||
@override
|
||||
Future<void> animateTo(
|
||||
double to, {
|
||||
@required Duration duration,
|
||||
@required Curve curve,
|
||||
required Duration duration,
|
||||
required Curve curve,
|
||||
}) {
|
||||
if (nearEqual(to, pixels, physics.tolerance.distance)) {
|
||||
// 跳过动画,直接移到我们已经靠近的位置。
|
||||
|
||||
Reference in New Issue
Block a user