Skip to content

Commit

Permalink
BouncingScrollPhysics should propagate decelerationRate. (#115797)
Browse files Browse the repository at this point in the history
  • Loading branch information
moffatman authored Nov 22, 2022
1 parent 0d7a3b7 commit 3fe7794
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/flutter/lib/src/widgets/scroll_physics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,10 @@ class BouncingScrollPhysics extends ScrollPhysics {

@override
BouncingScrollPhysics applyTo(ScrollPhysics? ancestor) {
return BouncingScrollPhysics(parent: buildParent(ancestor));
return BouncingScrollPhysics(
parent: buildParent(ancestor),
decelerationRate: decelerationRate
);
}

/// The multiple applied to overscroll to make it appear that scrolling past
Expand Down
6 changes: 6 additions & 0 deletions packages/flutter/test/widgets/scroll_physics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ void main() {
const ScrollPhysics never = NeverScrollableScrollPhysics();
const ScrollPhysics always = AlwaysScrollableScrollPhysics();
const ScrollPhysics page = PageScrollPhysics();
const ScrollPhysics bounceDesktop = BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast);

String types(ScrollPhysics? value) => value!.parent == null ? '${value.runtimeType}' : '${value.runtimeType} ${types(value.parent)}';

Expand Down Expand Up @@ -92,6 +93,11 @@ void main() {
types(page.applyTo(bounce.applyTo(clamp.applyTo(never.applyTo(always))))),
'PageScrollPhysics BouncingScrollPhysics ClampingScrollPhysics NeverScrollableScrollPhysics AlwaysScrollableScrollPhysics',
);

expect(
bounceDesktop.applyTo(always),
(BouncingScrollPhysics x) => x.decelerationRate == ScrollDecelerationRate.fast
);
});

test("ScrollPhysics scrolling subclasses - Creating the simulation doesn't alter the velocity for time 0", () {
Expand Down

0 comments on commit 3fe7794

Please sign in to comment.