Commit 2e998661 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Use sliver-based scrolling in more places (#7893)

In particular, we now use ListView in the about dialog.
parent 3addac54
......@@ -52,24 +52,6 @@ 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) {
......@@ -91,10 +73,15 @@ class ComplexLayoutState extends State<ComplexLayout> {
body: new Column(
children: <Widget>[
new Expanded(
child: new LazyBlock(
child: new ListView.builder(
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(),
],
......
......@@ -447,15 +447,14 @@ class _LicensePageState extends State<LicensePage> {
),
body: new DefaultTextStyle(
style: Theme.of(context).textTheme.caption,
child: new Scrollbar(
child: new LazyBlock(
child: new Scrollbar2(
child: new ListView(
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 12.0),
delegate: new LazyBlockChildren(
children: contents
)
)
)
)
shrinkWrap: true,
children: contents,
),
),
),
);
}
}
......
......@@ -7,29 +7,29 @@ import 'package:flutter/widgets.dart';
void main() {
testWidgets('Scroll flings twice in a row does not crash', (WidgetTester tester) async {
await tester.pumpWidget(new Block(
await tester.pumpWidget(new ListView(
children: <Widget>[
new Container(height: 100000.0)
]
));
ScrollableState scrollable =
tester.state<ScrollableState>(find.byType(Scrollable));
Scrollable2State scrollable =
tester.state<Scrollable2State>(find.byType(Scrollable2));
expect(scrollable.scrollOffset, equals(0.0));
expect(scrollable.position.pixels, equals(0.0));
await tester.flingFrom(const Point(200.0, 300.0), const Offset(0.0, -200.0), 500.0);
await tester.pump();
await tester.pump(const Duration(seconds: 5));
expect(scrollable.scrollOffset, greaterThan(0.0));
expect(scrollable.position.pixels, greaterThan(0.0));
double oldOffset = scrollable.scrollOffset;
double oldOffset = scrollable.position.pixels;
await tester.flingFrom(const Point(200.0, 300.0), const Offset(0.0, -200.0), 500.0);
await tester.pump();
await tester.pump(const Duration(seconds: 5));
expect(scrollable.scrollOffset, greaterThan(oldOffset));
expect(scrollable.position.pixels, greaterThan(oldOffset));
});
}
......@@ -21,8 +21,8 @@ Widget buildCard(BuildContext context, int index) {
}
Widget buildFrame() {
return new LazyBlock(
delegate: new LazyBlockBuilder(builder: buildCard)
return new ListView.builder(
itemBuilder: buildCard,
);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment