Simplify macrobencharks/picture_cache (#62219)
This commit is contained in:
@@ -10,69 +10,39 @@ class PictureCachePage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: DefaultTabController(
|
||||
length: kTabNames.length, // This is the number of tabs.
|
||||
child: NestedScrollView(
|
||||
key: const Key('nested-scroll'), // this key is used by the driver test
|
||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||
// These are the slivers that show up in the "outer" scroll view.
|
||||
return <Widget>[
|
||||
SliverOverlapAbsorber(
|
||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||
sliver: SliverAppBar(
|
||||
title: const Text('Picture Cache'),
|
||||
pinned: true,
|
||||
expandedHeight: 50.0,
|
||||
forceElevated: innerBoxIsScrolled,
|
||||
bottom: TabBar(
|
||||
tabs: kTabNames.map((String name) => Tab(text: name)).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
];
|
||||
},
|
||||
body: TabBarView(
|
||||
children: kTabNames.map((String name) {
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return VerticalList();
|
||||
},
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
return DefaultTabController(
|
||||
length: kTabNames.length, // This is the number of tabs.
|
||||
child: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Picture Cache'),
|
||||
// pinned: true,
|
||||
// expandedHeight: 50.0,
|
||||
// forceElevated: innerBoxIsScrolled,
|
||||
bottom: TabBar(
|
||||
tabs: kTabNames.map((String name) => Tab(text: name)).toList(),
|
||||
),
|
||||
),
|
||||
body: TabBarView(
|
||||
key: const Key('tabbar_view'), // this key is used by the driver test
|
||||
children: kTabNames.map((String name) {
|
||||
return SafeArea(
|
||||
top: false,
|
||||
bottom: false,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return ListView.builder(
|
||||
itemBuilder: (BuildContext context, int index) => ListItem(index: index),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class VerticalList extends StatelessWidget {
|
||||
static const int kItemCount = 100;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
SliverOverlapInjector(
|
||||
// This is the flip side of the SliverOverlapAbsorber above.
|
||||
handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),
|
||||
),
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) => ListItem(index: index),
|
||||
childCount: kItemCount,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ListItem extends StatelessWidget {
|
||||
const ListItem({Key key, this.index})
|
||||
: super(key: key);
|
||||
|
||||
@@ -13,9 +13,10 @@ void main() {
|
||||
kPictureCacheRouteName,
|
||||
pageDelay: const Duration(seconds: 1),
|
||||
driverOps: (FlutterDriver driver) async {
|
||||
final SerializableFinder nestedScroll = find.byValueKey('nested-scroll');
|
||||
final SerializableFinder tabBarView = find.byValueKey('tabbar_view');
|
||||
Future<void> _scrollOnce(double offset) async {
|
||||
await driver.scroll(nestedScroll, offset, 0.0, const Duration(milliseconds: 300));
|
||||
// Technically it's not scrolling but moving
|
||||
await driver.scroll(tabBarView, offset, 0.0, const Duration(milliseconds: 300));
|
||||
await Future<void>.delayed(const Duration(milliseconds: 500));
|
||||
}
|
||||
for (int i = 0; i < 3; i += 1) {
|
||||
|
||||
Reference in New Issue
Block a user