mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Switch complex_layout back to LazyBlock (#7940)
We need to study these benchmark numbers more carefully. See #7937
This commit is contained in:
parent
e01470a813
commit
474c2c7df6
@ -52,6 +52,24 @@ class ComplexLayout extends StatefulWidget {
|
||||
static ComplexLayoutState of(BuildContext context) => context.ancestorStateOfType(const TypeMatcher<ComplexLayoutState>());
|
||||
}
|
||||
|
||||
class FancyItemDelegate extends LazyBlockDelegate {
|
||||
@override
|
||||
Widget buildItem(BuildContext context, int index) {
|
||||
if (index % 2 == 0)
|
||||
return new FancyImageItem(index, key: new ValueKey<int>(index));
|
||||
else
|
||||
return new FancyGalleryItem(index, key: new ValueKey<int>(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<ComplexLayout> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -73,15 +91,10 @@ class ComplexLayoutState extends State<ComplexLayout> {
|
||||
body: new Column(
|
||||
children: <Widget>[
|
||||
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<int>(index));
|
||||
else
|
||||
return new FancyGalleryItem(index, key: new ValueKey<int>(index));
|
||||
},
|
||||
),
|
||||
delegate: new FancyItemDelegate(),
|
||||
)
|
||||
),
|
||||
new BottomBar(),
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user