@@ -178,10 +178,28 @@ 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
+ /// The top speed to move at, in logical pixels per second.
182
+ ///
183
+ /// This will be the speed whenever the distance to be traveled
184
+ /// is long enough to take at least [minDuration] at this speed.
185
+ ///
186
+ /// This is chosen to equal the top speed that can be produced
187
+ /// by a fling gesture in a Flutter [ScrollView] ,
188
+ /// which in turn was chosen to equal the top speed of
189
+ /// an (initial) fling gesture in a native Android scroll view.
190
+ const double topSpeed = 8000 ;
191
+
192
+ /// The desired duration of the animation when traveling short distances.
193
+ ///
194
+ /// The speed will be chosen so that traveling the distance
195
+ /// will take this long, whenever that distance is short enough
196
+ /// that that means a speed of at most [topSpeed] .
197
+ const minDuration = Duration (milliseconds: 300 );
198
+
181
199
final target = maxScrollExtent;
182
200
final distance = target - pixels;
183
- final durationMsAtSpeedLimit = (1000 * distance / 8000 ).ceil ();
184
- final durationMs = math.max (300 , durationMsAtSpeedLimit);
201
+ final durationMsAtSpeedLimit = (1000 * distance / topSpeed ).ceil ();
202
+ final durationMs = math.max (minDuration.inMilliseconds , durationMsAtSpeedLimit);
185
203
animateTo (
186
204
target,
187
205
duration: Duration (milliseconds: durationMs),
0 commit comments