@@ -384,6 +384,15 @@ 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
+ final target = maxScrollExtent;
388
+
389
+ final tolerance = physics.toleranceFor (this );
390
+ if (nearEqual (pixels, target, tolerance.distance)) {
391
+ // Skip the animation; jump right to the target, which is already close.
392
+ jumpTo (target);
393
+ return ;
394
+ }
395
+
387
396
/// The top speed to move at, in logical pixels per second.
388
397
///
389
398
/// This will be the speed whenever the distance to be traveled
@@ -402,12 +411,12 @@ class MessageListScrollPosition extends ScrollPositionWithSingleContext {
402
411
/// that that means a speed of at most [topSpeed] .
403
412
const minDuration = Duration (milliseconds: 300 );
404
413
405
- final target = maxScrollExtent;
406
414
final durationSecAtSpeedLimit = (target - pixels) / topSpeed;
407
415
final durationSec = math.max (durationSecAtSpeedLimit,
408
416
minDuration.inMilliseconds / 1000.0 );
409
417
final duration = Duration (milliseconds: (durationSec * 1000.0 ).ceil ());
410
- animateTo (target, duration: duration, curve: Curves .linear);
418
+ beginActivity (DrivenScrollActivity (this , vsync: context.vsync,
419
+ from: pixels, to: target, duration: duration, curve: Curves .linear));
411
420
}
412
421
}
413
422
0 commit comments