diff --git a/dev/benchmarks/complex_layout/lib/main.dart b/dev/benchmarks/complex_layout/lib/main.dart index 282e579ef1b..a7dac640398 100644 --- a/dev/benchmarks/complex_layout/lib/main.dart +++ b/dev/benchmarks/complex_layout/lib/main.dart @@ -52,6 +52,24 @@ class ComplexLayout extends StatefulWidget { static ComplexLayoutState of(BuildContext context) => context.ancestorStateOfType(const TypeMatcher()); } +class FancyItemDelegate extends LazyBlockDelegate { + @override + Widget buildItem(BuildContext context, int index) { + if (index % 2 == 0) + return new FancyImageItem(index, key: new ValueKey(index)); + else + return new FancyGalleryItem(index, key: new ValueKey(index)); + } + + @override + bool shouldRebuild(FancyItemDelegate oldDelegate) => false; + + @override + double estimateTotalExtent(int firstIndex, int lastIndex, double minOffset, double firstStartOffset, double lastEndOffset) { + return double.INFINITY; + } +} + class ComplexLayoutState extends State { @override Widget build(BuildContext context) { @@ -73,15 +91,10 @@ class ComplexLayoutState extends State { body: new Column( children: [ new Expanded( - child: new ListView.builder( + child: new LazyBlock( key: new Key('main-scroll'), // this key is used by the driver test - itemBuilder: (BuildContext context, int index) { - if (index % 2 == 0) - return new FancyImageItem(index, key: new ValueKey(index)); - else - return new FancyGalleryItem(index, key: new ValueKey(index)); - }, - ), + delegate: new FancyItemDelegate(), + ) ), new BottomBar(), ],