Port complex_layout to Sliver-based scrolling (#8114)
This commit is contained in:
@@ -52,28 +52,9 @@ class ComplexLayout extends StatefulWidget {
|
|||||||
static ComplexLayoutState of(BuildContext context) => context.ancestorStateOfType(const TypeMatcher<ComplexLayoutState>());
|
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> {
|
class ComplexLayoutState extends State<ComplexLayout> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
return new Scaffold(
|
return new Scaffold(
|
||||||
appBar: new AppBar(
|
appBar: new AppBar(
|
||||||
title: new Text('Advanced Layout'),
|
title: new Text('Advanced Layout'),
|
||||||
@@ -91,9 +72,14 @@ class ComplexLayoutState extends State<ComplexLayout> {
|
|||||||
body: new Column(
|
body: new Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Expanded(
|
new Expanded(
|
||||||
child: new LazyBlock(
|
child: new ListView.builder(
|
||||||
key: new Key('main-scroll'), // this key is used by the driver test
|
key: new Key('main-scroll'), // this key is used by the driver test
|
||||||
delegate: new FancyItemDelegate(),
|
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));
|
||||||
|
},
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
new BottomBar(),
|
new BottomBar(),
|
||||||
|
|||||||
Reference in New Issue
Block a user