diff --git a/package/lib/src/foundation/sheet_activity.dart b/package/lib/src/foundation/sheet_activity.dart index 21fc246f..c436aaa5 100644 --- a/package/lib/src/foundation/sheet_activity.dart +++ b/package/lib/src/foundation/sheet_activity.dart @@ -88,14 +88,19 @@ abstract class SheetActivity { case > 0: // Prevents the sheet from being pushed off the screen by the keyboard. final correction = min(0.0, metrics.maxViewPixels - metrics.viewPixels); - owner.setPixels(oldPixels + correction); + owner + ..setPixels(oldPixels + correction) + ..dispatchUpdateNotification(); case < 0: // Appends the delta of the bottom inset (typically the keyboard height) // to keep the visual sheet position unchanged. - owner.setPixels( - min(oldPixels - deltaInsetBottom, owner.metrics.maxPixels), - ); + owner + ..setPixels(min( + oldPixels - deltaInsetBottom, + owner.metrics.maxPixels, + )) + ..dispatchUpdateNotification(); } owner.settle(); @@ -177,7 +182,9 @@ class AnimatedSheetActivity extends SheetActivity final newInsets = owner.metrics.viewportInsets; final oldInsets = oldViewportInsets ?? newInsets; final deltaInsetBottom = newInsets.bottom - oldInsets.bottom; - owner.setPixels(owner.metrics.pixels - deltaInsetBottom); + owner + ..setPixels(owner.metrics.pixels - deltaInsetBottom) + ..dispatchUpdateNotification(); // 2. If the animation is still running, we start a new linear animation // to bring the sheet position to the recalculated final position in the @@ -252,17 +259,21 @@ class DragSheetActivity extends SheetActivity } @override - void applyUserDragUpdate(Offset offset) { + void applyUserDragUpdate(SheetDragUpdateDetails details) { final physicsAppliedDelta = - owner.physics.applyPhysicsToOffset(offset.dy, owner.metrics); + owner.physics.applyPhysicsToOffset(details.deltaY, owner.metrics); if (physicsAppliedDelta != 0) { - owner.setPixels(owner.metrics.pixels + physicsAppliedDelta); + owner + ..setPixels(owner.metrics.pixels + physicsAppliedDelta) + ..dispatchDragUpdateNotification(details: details); } } @override - void applyUserDragEnd(Velocity velocity) { - owner.goBallistic(velocity.pixelsPerSecond.dy); + void applyUserDragEnd(SheetDragEndDetails details) { + owner + ..dispatchDragEndNotification(details: details) + ..goBallistic(details.velocityY); } } @@ -298,7 +309,9 @@ mixin ControlledSheetActivityMixin on SheetActivity { void onAnimationTick() { if (mounted) { final oldPixels = owner.metrics.pixels; - owner.setPixels(oldPixels + controller.value - _lastAnimatedValue); + owner + ..setPixels(oldPixels + controller.value - _lastAnimatedValue) + ..dispatchUpdateNotification(); _lastAnimatedValue = controller.value; } } @@ -331,7 +344,9 @@ mixin UserControlledSheetActivityMixin final deltaInsetBottom = newInsets.bottom - oldInsets.bottom; // Appends the delta of the bottom inset (typically the keyboard height) // to keep the visual sheet position unchanged. - owner.setPixels(owner.metrics.pixels - deltaInsetBottom); + owner + ..setPixels(owner.metrics.pixels - deltaInsetBottom) + ..dispatchUpdateNotification(); // We don't call `goSettling` here because the user is still // manually controlling the sheet position. } diff --git a/package/lib/src/foundation/sheet_drag.dart b/package/lib/src/foundation/sheet_drag.dart index 2fbeb3ed..103af025 100644 --- a/package/lib/src/foundation/sheet_drag.dart +++ b/package/lib/src/foundation/sheet_drag.dart @@ -217,8 +217,8 @@ class SheetDragEndDetails extends SheetDragDetails { @internal abstract class SheetDragControllerTarget { VerticalDirection get dragAxisDirection; - void applyUserDragUpdate(Offset offset); - void applyUserDragEnd(Velocity velocity); + void applyUserDragUpdate(SheetDragUpdateDetails details); + void applyUserDragEnd(SheetDragEndDetails details); /// Returns the minimum number of pixels that the sheet being dragged /// will potentially consume for the given drag delta. @@ -318,7 +318,7 @@ class SheetDragController implements Drag, ScrollActivityDelegate { } _lastDetails = details; - _target!.applyUserDragEnd(details.velocity); + _target!.applyUserDragEnd(details); } /// Called by the [ScrollDragController] in [Drag.update]. @@ -349,7 +349,7 @@ class SheetDragController implements Drag, ScrollActivityDelegate { } _lastDetails = details; - _target!.applyUserDragUpdate(details.delta); + _target!.applyUserDragUpdate(details); } @override diff --git a/package/lib/src/scrollable/scrollable_sheet_activity.dart b/package/lib/src/scrollable/scrollable_sheet_activity.dart index 1464a727..0cdd05d1 100644 --- a/package/lib/src/scrollable/scrollable_sheet_activity.dart +++ b/package/lib/src/scrollable/scrollable_sheet_activity.dart @@ -111,7 +111,6 @@ abstract class ScrollableSheetActivity final overflow = owner.physics.computeOverflow(delta, owner.metrics); if (overflow.abs() > 0) { position.didOverscrollBy(overflow); - owner.dispatchOverflowNotification(overflow: overflow); return overflow; } @@ -177,19 +176,29 @@ class DragScrollDrivenSheetActivity extends ScrollableSheetActivity } @override - void applyUserDragUpdate(Offset delta) { - scrollPosition.userScrollDirection = - delta.dy > 0.0 ? ScrollDirection.forward : ScrollDirection.reverse; - _applyScrollOffset(-1 * delta.dy); + void applyUserDragUpdate(SheetDragUpdateDetails details) { + scrollPosition.userScrollDirection = details.deltaY > 0.0 + ? ScrollDirection.forward + : ScrollDirection.reverse; + final oldPixels = owner.metrics.pixels; + final overflow = _applyScrollOffset(-1 * details.deltaY); + if (owner.metrics.pixels != oldPixels) { + owner.dispatchDragUpdateNotification(details: details); + } + if (overflow > 0) { + owner.dispatchOverflowNotification(overflow: overflow); + } } @override - void applyUserDragEnd(Velocity velocity) { - owner.goBallisticWithScrollPosition( - velocity: -1 * velocity.pixelsPerSecond.dy, - shouldIgnorePointer: false, - scrollPosition: scrollPosition, - ); + void applyUserDragEnd(SheetDragEndDetails details) { + owner + ..dispatchDragEndNotification(details: details) + ..goBallisticWithScrollPosition( + velocity: -1 * details.velocityY, + shouldIgnorePointer: false, + scrollPosition: scrollPosition, + ); } } @@ -230,10 +239,14 @@ class BallisticScrollDrivenSheetActivity extends ScrollableSheetActivity void onAnimationTick() { final delta = controller.value - _oldPixels; _oldPixels = controller.value; - final overscroll = _applyScrollOffset(delta); - - if (!overscroll.isApprox(0)) { - owner.goIdleWithScrollPosition(); + final overflow = _applyScrollOffset(delta); + if (owner.metrics.pixels != _oldPixels) { + owner.dispatchUpdateNotification(); + } + if (!overflow.isApprox(0)) { + owner + ..dispatchOverflowNotification(overflow: overflow) + ..goIdleWithScrollPosition(); return; }