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:
@@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user