@@ -384,10 +384,28 @@ class MessageListScrollPosition extends ScrollPositionWithSingleContext {
384
384
/// at the start of the animation, even if that ends up being more or less far
385
385
/// than the actual extent of the content.
386
386
void scrollToEnd () {
387
+ /// The top speed to move at, in logical pixels per second.
388
+ ///
389
+ /// This will be the speed whenever the distance to be traveled
390
+ /// is long enough to take at least [minDuration] at this speed.
391
+ ///
392
+ /// This is chosen to equal the top speed that can be produced
393
+ /// by a fling gesture in a Flutter [ScrollView] ,
394
+ /// which in turn was chosen to equal the top speed of
395
+ /// an (initial) fling gesture in a native Android scroll view.
396
+ const double topSpeed = 8000 ;
397
+
398
+ /// The desired duration of the animation when traveling short distances.
399
+ ///
400
+ /// The speed will be chosen so that traveling the distance
401
+ /// will take this long, whenever that distance is short enough
402
+ /// that that means a speed of at most [topSpeed] .
403
+ const minDuration = Duration (milliseconds: 300 );
404
+
387
405
final target = maxScrollExtent;
388
406
final distance = target - pixels;
389
- final durationMsAtSpeedLimit = (1000 * distance / 8000 ).ceil ();
390
- final durationMs = math.max (300 , durationMsAtSpeedLimit);
407
+ final durationMsAtSpeedLimit = (1000 * distance / topSpeed ).ceil ();
408
+ final durationMs = math.max (minDuration.inMilliseconds , durationMsAtSpeedLimit);
391
409
animateTo (
392
410
target,
393
411
duration: Duration (milliseconds: durationMs),
0 commit comments