@@ -178,6 +178,15 @@ class MessageListScrollPosition extends ScrollPositionWithSingleContext {
178
178
/// at the start of the animation, even if that ends up being more or less far
179
179
/// than the actual extent of the content.
180
180
void scrollToEnd () {
181
+ final target = maxScrollExtent;
182
+
183
+ final tolerance = physics.toleranceFor (this );
184
+ if (nearEqual (pixels, target, tolerance.distance)) {
185
+ // Skip the animation; jump right to the target, which is already close.
186
+ jumpTo (target);
187
+ return ;
188
+ }
189
+
181
190
/// The top speed to move at, in logical pixels per second.
182
191
///
183
192
/// This will be the speed whenever the distance to be traveled
@@ -196,12 +205,12 @@ class MessageListScrollPosition extends ScrollPositionWithSingleContext {
196
205
/// that that means a speed of at most [topSpeed] .
197
206
const minDuration = Duration (milliseconds: 300 );
198
207
199
- final target = maxScrollExtent;
200
208
final durationSecAtSpeedLimit = (target - pixels) / topSpeed;
201
209
final durationSec = math.max (durationSecAtSpeedLimit,
202
210
minDuration.inMilliseconds / 1000.0 );
203
211
final duration = Duration (milliseconds: (durationSec * 1000.0 ).ceil ());
204
- animateTo (target, duration: duration, curve: Curves .linear);
212
+ beginActivity (DrivenScrollActivity (this , vsync: context.vsync,
213
+ from: pixels, to: target, duration: duration, curve: Curves .linear));
205
214
}
206
215
}
207
216
0 commit comments