refactor: rely on platform scroll physics and add scroll behavior tests

This commit is contained in:
R-Bharathraj
2026-09-18 17:01:17 +05:30
parent 5122eebc11
commit 4adc21a277
3 changed files with 110 additions and 18 deletions

View File

@@ -46,12 +46,16 @@ class KrowApp extends StatelessWidget {
class KrowScrollBehavior extends MaterialScrollBehavior {
const KrowScrollBehavior();
/// Bouncing on every platform. The lists here sit under a pinned header, and
/// a rubber-band edge shows you have reached the end of the content rather
/// than the end of the screen — clamping just stops dead against the header.
@override
ScrollPhysics getScrollPhysics(BuildContext context) =>
const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics());
// Scroll physics is deliberately left to the platform.
//
// Forcing BouncingScrollPhysics everywhere looked smoother on a long list
// and broke every short one: ScrollView's constructor hands any vertical
// list without a controller an AlwaysScrollableScrollPhysics, which is
// applied over whatever the behaviour returns and answers
// shouldAcceptUserOffset true regardless of content. Bouncing then let
// content that already fits be dragged away from the header, leaving a gap
// down the screen. Android's clamping accepts the same drag and pins it to
// the boundary, so nothing moves; iOS bounces, which is its own convention.
/// Let the web and desktop builds be dragged with a mouse or trackpad, not
/// only scrolled with a wheel.
@@ -62,12 +66,4 @@ class KrowScrollBehavior extends MaterialScrollBehavior {
PointerDeviceKind.trackpad,
PointerDeviceKind.stylus,
};
/// The bounce is the end-of-list signal; a glow on top of it is noise.
@override
Widget buildOverscrollIndicator(
BuildContext context,
Widget child,
ScrollableDetails details,
) => child;
}