Files
buzz/mobile/third_party/scrollable_positioned_list
Wes 5ac5984f97 perf(mobile): keep chat rows mounted when a message arrives
scrollable_positioned_list keys every item by index. The chat list is
reversed, so a new message moves every row to a new key and Flutter
remounts every built row: hooks, markdown parses and image listeners.

Add an optional findChildIndexCallback to the vendored package. With it
set, an item keeps its own key and the callback finds its new index, the
way ListView does. Item positions now read the index from the item
wrapper instead of its key. The chat timeline maps each row key to its
index.

Co-authored-by: Carl <32a2e2c9d428ee08902cab75d956da2c1d235a22d4766b0dd4138bf6e2e5db1d@buzz.block.builderlab.xyz>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Wes <wesbillman@users.noreply.github.com>
2026-10-19 10:15:26 -07:00
..
…
…

scrollable_positioned_list

A flutter list that allows scrolling to a specific item in the list.

Also allows determining what items are currently visible.

Usage

A ScrollablePositionedList works much like the builder version of ListView except that the list can be scrolled or jumped to a specific item.

Example

A ScrollablePositionedList can be created with:

final ItemScrollController itemScrollController = ItemScrollController();
final ScrollOffsetController scrollOffsetController = ScrollOffsetController();
final ItemPositionsListener itemPositionsListener = ItemPositionsListener.create();
final ScrollOffsetListener scrollOffsetListener = ScrollOffsetListener.create()

ScrollablePositionedList.builder(
  itemCount: 500,
  itemBuilder: (context, index) => Text('Item $index'),
  itemScrollController: itemScrollController,
  scrollOffsetController: scrollOffsetController,
  itemPositionsListener: itemPositionsListener,
  scrollOffsetListener: scrollOffsetListener,
);

One then can scroll to a particular item with:

itemScrollController.scrollTo(
  index: 150,
  duration: Duration(seconds: 2),
  curve: Curves.easeInOutCubic);

or jump to a particular item with:

itemScrollController.jumpTo(index: 150);

One can monitor what items are visible on screen with:

itemPositionsListener.itemPositions.addListener(() => ...);

Experimental APIs (subject to bugs and changes)

Changes in scroll position can be monitored with:

scrollOffsetListener.changes.listen((event) => ...)

see ScrollSum in this test for an example of how the current offset can be calculated from the stream of scroll change deltas. This feature is new and experimental.

Changes in scroll position in pixels, relative to the current scroll position, can be made with:

scrollOffsetController.animateScroll(offset: 100, duration: Duration(seconds: 1));

A full example can be found in the example folder.


This is not an officially supported Google product.