Improved support for saving and restoring the scroll offset, etc V2 (#10590)

This commit is contained in:
Hans Muller
2017-06-08 17:20:36 -07:00
committed by GitHub
parent 435c25bfc4
commit 0e4dda7736
10 changed files with 200 additions and 57 deletions

View File

@@ -111,9 +111,9 @@ class ComplexLayoutState extends State<ComplexLayout> {
key: const Key('complex-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));
return new FancyImageItem(index, key: new PageStorageKey<int>(index));
else
return new FancyGalleryItem(index, key: new ValueKey<int>(index));
return new FancyGalleryItem(index, key: new PageStorageKey<int>(index));
},
)
),
@@ -496,7 +496,7 @@ class ItemGalleryBox extends StatelessWidget {
child: new TabBarView(
children: tabNames.map((String tabName) {
return new Container(
key: new Key(tabName),
key: new PageStorageKey<String>(tabName),
child: new Padding(
padding: const EdgeInsets.all(8.0),
child: new Card(
@@ -611,6 +611,7 @@ class GalleryDrawer extends StatelessWidget {
final ScrollMode currentMode = ComplexLayoutApp.of(context).scrollMode;
return new Drawer(
child: new ListView(
key: const PageStorageKey<String>('gallery-drawer'),
children: <Widget>[
new FancyDrawerHeader(),
new ListTile(