Introduce ScrollableList2

ScrollableList2 uses the same pattern as ScrollableGrid, which requires the
client to allocate widgets for every list item but doesn't inflate them unless
they're actually needed for the view. It improves on the original
ScrollableList by not requiring a rebuild of the whole visible portion of the
list when scrolling. In fact, small scrolls can often be handled entirely by
repainting.
This commit is contained in:
Adam Barth
2016-01-04 14:38:44 -08:00
parent 888dc770c8
commit 99bca282c9
9 changed files with 427 additions and 174 deletions

View File

@@ -72,13 +72,14 @@ class MediaQueryExample extends StatelessComponent {
items.add(new AdaptiveItem("Item $i"));
if (MediaQuery.of(context).size.width < _gridViewBreakpoint) {
return new Block(
items.map((AdaptiveItem item) => item.toListItem()).toList()
return new ScrollableList2(
itemExtent: 50.0,
children: items.map((AdaptiveItem item) => item.toListItem()).toList()
);
} else {
return new ScrollableGrid(
children: items.map((AdaptiveItem item) => item.toCard()).toList(),
delegate: new MaxTileWidthGridDelegate(maxTileWidth: _maxTileWidth)
delegate: new MaxTileWidthGridDelegate(maxTileWidth: _maxTileWidth),
children: items.map((AdaptiveItem item) => item.toCard()).toList()
);
}
}