Skip to content

Commit c3dcb77

Browse files
committed
scroll [nfc]: Clarify scroll-to-end calculations a bit more
This version keeps the numbers in the form of doubles, with seconds as the unit of time, until the end. That's a bit more typical Flutter style, and also brings it closer to how the logic will look when we flip this around to produce a velocity instead of a duration.
1 parent aa42c38 commit c3dcb77

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/widgets/scrolling.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,11 @@ class MessageListScrollPosition extends ScrollPositionWithSingleContext {
403403
const minDuration = Duration(milliseconds: 300);
404404

405405
final target = maxScrollExtent;
406-
final distance = target - pixels;
407-
final durationMsAtSpeedLimit = (1000 * distance / topSpeed).ceil();
408-
final durationMs = math.max(minDuration.inMilliseconds, durationMsAtSpeedLimit);
409-
animateTo(
410-
target,
411-
duration: Duration(milliseconds: durationMs),
412-
curve: Curves.linear);
406+
final durationSecAtSpeedLimit = (target - pixels) / topSpeed;
407+
final durationSec = math.max(durationSecAtSpeedLimit,
408+
minDuration.inMilliseconds / 1000.0);
409+
final duration = Duration(milliseconds: (durationSec * 1000.0).ceil());
410+
animateTo(target, duration: duration, curve: Curves.linear);
413411
}
414412
}
415413

0 commit comments

Comments
 (0)