Skip to content

Commit 3fe7794

Browse files
authored
BouncingScrollPhysics should propagate decelerationRate. (#115797)
1 parent 0d7a3b7 commit 3fe7794

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/flutter/lib/src/widgets/scroll_physics.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,10 @@ class BouncingScrollPhysics extends ScrollPhysics {
629629

630630
@override
631631
BouncingScrollPhysics applyTo(ScrollPhysics? ancestor) {
632-
return BouncingScrollPhysics(parent: buildParent(ancestor));
632+
return BouncingScrollPhysics(
633+
parent: buildParent(ancestor),
634+
decelerationRate: decelerationRate
635+
);
633636
}
634637

635638
/// The multiple applied to overscroll to make it appear that scrolling past

packages/flutter/test/widgets/scroll_physics_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ void main() {
6565
const ScrollPhysics never = NeverScrollableScrollPhysics();
6666
const ScrollPhysics always = AlwaysScrollableScrollPhysics();
6767
const ScrollPhysics page = PageScrollPhysics();
68+
const ScrollPhysics bounceDesktop = BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast);
6869

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

@@ -92,6 +93,11 @@ void main() {
9293
types(page.applyTo(bounce.applyTo(clamp.applyTo(never.applyTo(always))))),
9394
'PageScrollPhysics BouncingScrollPhysics ClampingScrollPhysics NeverScrollableScrollPhysics AlwaysScrollableScrollPhysics',
9495
);
96+
97+
expect(
98+
bounceDesktop.applyTo(always),
99+
(BouncingScrollPhysics x) => x.decelerationRate == ScrollDecelerationRate.fast
100+
);
95101
});
96102

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

0 commit comments

Comments
 (0)