Unverified Commit 98264a47 authored by Ming Lyu (CareF)'s avatar Ming Lyu (CareF) Committed by GitHub

Simplify macrobencharks/picture_cache (#62219)

parent c867a1ed
...@@ -10,65 +10,35 @@ class PictureCachePage extends StatelessWidget { ...@@ -10,65 +10,35 @@ class PictureCachePage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return DefaultTabController(
body: DefaultTabController(
length: kTabNames.length, // This is the number of tabs. length: kTabNames.length, // This is the number of tabs.
child: NestedScrollView( child: Scaffold(
key: const Key('nested-scroll'), // this key is used by the driver test appBar: AppBar(
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'), title: const Text('Picture Cache'),
pinned: true, // pinned: true,
expandedHeight: 50.0, // expandedHeight: 50.0,
forceElevated: innerBoxIsScrolled, // forceElevated: innerBoxIsScrolled,
bottom: TabBar( bottom: TabBar(
tabs: kTabNames.map((String name) => Tab(text: name)).toList(), tabs: kTabNames.map((String name) => Tab(text: name)).toList(),
), ),
), ),
),
];
},
body: TabBarView( body: TabBarView(
key: const Key('tabbar_view'), // this key is used by the driver test
children: kTabNames.map((String name) { children: kTabNames.map((String name) {
return SafeArea( return SafeArea(
top: false, top: false,
bottom: false, bottom: false,
child: Builder( child: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return VerticalList(); return ListView.builder(
itemBuilder: (BuildContext context, int index) => ListItem(index: index),
);
}, },
), ),
); );
}).toList(), }).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,
),
),
],
); );
} }
} }
......
...@@ -13,9 +13,10 @@ void main() { ...@@ -13,9 +13,10 @@ void main() {
kPictureCacheRouteName, kPictureCacheRouteName,
pageDelay: const Duration(seconds: 1), pageDelay: const Duration(seconds: 1),
driverOps: (FlutterDriver driver) async { driverOps: (FlutterDriver driver) async {
final SerializableFinder nestedScroll = find.byValueKey('nested-scroll'); final SerializableFinder tabBarView = find.byValueKey('tabbar_view');
Future<void> _scrollOnce(double offset) async { 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)); await Future<void>.delayed(const Duration(milliseconds: 500));
} }
for (int i = 0; i < 3; i += 1) { for (int i = 0; i < 3; i += 1) {
......
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