Adds a first draft of LazyBlock

LazyBlock is intended as a replacement for MixedViewport. Rather than

maintaining a table of all the observed child sizes (like

MixedViewport), LazyBlock works by dead reckoning the location of the

children based on the existing viewport. This approach makes it easier

to resize children because LazyBlock doesn't cache any additional

information that would need to be invalidated.



This patch contains a first draft of LazyBlock that works in a simple

usage scenario. Subsequent patches will replace

ScrollableMixedWidgetList with LazyBlock and port the existing

ScrollableMixedWidgetList tests over to LazyBlock.



Related to #3075
This commit is contained in:
Adam Barth
2016-04-05 14:13:31 -07:00
parent b9f048172d
commit 618e7e4942
12 changed files with 564 additions and 27 deletions

View File

@@ -49,6 +49,19 @@ class ComplexLayout extends StatefulWidget {
}
class FancyItemDelegate extends LazyBlockDelegate {
@override
Widget buildItem(BuildContext context, int index) {
if (index % 2 == 0)
return new FancyImageItem(index, key: new Key("Item $index"));
else
return new FancyGalleryItem(index, key: new Key("Item $index"));
}
@override
bool shouldRebuild(FancyItemDelegate oldDelegate) => false;
}
class ComplexLayoutState extends State<ComplexLayout> {
@override
Widget build(BuildContext context) {
@@ -70,14 +83,9 @@ class ComplexLayoutState extends State<ComplexLayout> {
body: new Column(
children: <Widget>[
new Flexible(
child: new ScrollableMixedWidgetList(
child: new LazyBlock(
key: new Key("main-scroll"),
builder: (BuildContext context, int index) {
if (index % 2 == 0)
return new FancyImageItem(index, key: new Key("Item $index"));
else
return new FancyGalleryItem(index, key: new Key("Item $index"));
}
delegate: new FancyItemDelegate()
)
),
new BottomBar()