@@ -259,6 +259,25 @@ class MessageListScrollPosition extends ScrollPositionWithSingleContext {
259
259
super .oldPosition,
260
260
super .debugLabel,
261
261
});
262
+
263
+ /// Like [applyContentDimensions] , but called without adjusting
264
+ /// the arguments to subtract the viewport dimension.
265
+ ///
266
+ /// For instance, if there is 100.0 pixels of scrollable content
267
+ /// of which 40.0 pixels is in the reverse-growing slivers and
268
+ /// 60.0 pixels in the forward-growing slivers, then the arguments
269
+ /// will be -40.0 and 60.0, regardless of the viewport dimension.
270
+ ///
271
+ /// By contrast in a call to [applyContentDimensions] , in this example and
272
+ /// if the viewport dimension is 80.0, then the arguments might be
273
+ /// 0.0 and 60.0, or -10.0 and 10.0, or -40.0 and 0.0, or other values,
274
+ /// depending on the value of [Viewport.anchor] .
275
+ bool applyContentDimensionsRaw (double wholeMinScrollExtent, double wholeMaxScrollExtent) {
276
+ // This makes the simplifying assumption that `anchor` is 1.0.
277
+ final effectiveMin = math.min (0.0 , wholeMinScrollExtent + viewportDimension);
278
+ final effectiveMax = wholeMaxScrollExtent;
279
+ return applyContentDimensions (effectiveMin, effectiveMax);
280
+ }
262
281
}
263
282
264
283
/// A version of [ScrollController] adapted for the Zulip message list.
@@ -449,10 +468,12 @@ class RenderMessageListViewport extends RenderCustomPaintOrderViewport {
449
468
if (correction != 0.0 ) {
450
469
offset.correctBy (correction);
451
470
} else {
452
- if (offset.applyContentDimensions (
453
- math.min (0.0 , _minScrollExtent + mainAxisExtent * anchor),
454
- math.max (0.0 , _maxScrollExtent - mainAxisExtent * (1.0 - anchor)),
455
- )) {
471
+ // TODO(upstream): Move applyContentDimensionsRaw to ViewportOffset
472
+ // (possibly with an API change to tell it [anchor]?);
473
+ // give it a default implementation calling applyContentDimensions;
474
+ // have RenderViewport.performLayout call it.
475
+ if ((offset as MessageListScrollPosition )
476
+ .applyContentDimensionsRaw (_minScrollExtent, _maxScrollExtent)) {
456
477
break ;
457
478
}
458
479
}
0 commit comments