From c7e2e8ae81f5b3048b07a399cf5fa8373e2430ce Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Tue, 19 Apr 2016 16:31:11 -0700 Subject: [PATCH] Remove Scaffold scrollableKey use in gallery demos (#3406) * Remove Scaffold scrollable_key demo usage --- examples/material_gallery/lib/demo/flexible_space_demo.dart | 3 --- examples/material_gallery/lib/demo/tabs_demo.dart | 1 - examples/material_gallery/lib/gallery/home.dart | 3 --- packages/flutter/lib/src/material/scaffold.dart | 6 ++++-- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/examples/material_gallery/lib/demo/flexible_space_demo.dart b/examples/material_gallery/lib/demo/flexible_space_demo.dart index 187b8be403..7fa4d63a64 100644 --- a/examples/material_gallery/lib/demo/flexible_space_demo.dart +++ b/examples/material_gallery/lib/demo/flexible_space_demo.dart @@ -77,7 +77,6 @@ class FlexibleSpaceDemo extends StatefulWidget { class FlexibleSpaceDemoState extends State { final GlobalKey _scaffoldKey = new GlobalKey(); final double _appBarHeight = 256.0; - final Key _scrollableKey = new UniqueKey(); AppBarBehavior _appBarBehavior = AppBarBehavior.scroll; @override @@ -90,7 +89,6 @@ class FlexibleSpaceDemoState extends State { ), child: new Scaffold( key: _scaffoldKey, - scrollableKey: _scrollableKey, appBarBehavior: _appBarBehavior, appBar: new AppBar( expandedHeight: _appBarHeight, @@ -132,7 +130,6 @@ class FlexibleSpaceDemoState extends State { ) ), body: new Block( - scrollableKey: _scrollableKey, padding: new EdgeInsets.only(top: _appBarHeight + statusBarHeight), children: [ new _ContactCategory( diff --git a/examples/material_gallery/lib/demo/tabs_demo.dart b/examples/material_gallery/lib/demo/tabs_demo.dart index f1bc22be12..0fb5ddd253 100644 --- a/examples/material_gallery/lib/demo/tabs_demo.dart +++ b/examples/material_gallery/lib/demo/tabs_demo.dart @@ -45,7 +45,6 @@ class TabsDemoState extends State { }); }, child: new Scaffold( - scrollableKey: _selectedPage.key, appBarBehavior: AppBarBehavior.under, appBar: new AppBar( title: new Text('Tabs and scrolling'), diff --git a/examples/material_gallery/lib/gallery/home.dart b/examples/material_gallery/lib/gallery/home.dart index ad577efcb4..5f58771906 100644 --- a/examples/material_gallery/lib/gallery/home.dart +++ b/examples/material_gallery/lib/gallery/home.dart @@ -75,7 +75,6 @@ class GalleryHome extends StatefulWidget { class GalleryHomeState extends State { final Key _homeKey = new ValueKey("Gallery Home"); - final Key _listKey = new ValueKey("Gallery List"); @override Widget build(BuildContext context) { @@ -98,12 +97,10 @@ class GalleryHomeState extends State { background: new GalleryHeader() ) ), - scrollableKey: _listKey, appBarBehavior: AppBarBehavior.under, body: new TwoLevelList( padding: new EdgeInsets.only(top: _kFlexibleSpaceMaxHeight + statusBarHight), type: MaterialListType.oneLine, - scrollableKey: _listKey, children: [ new TwoLevelSublist( leading: new Icon(icon: Icons.star), diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index 44550f12f7..53aa693d63 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -487,8 +487,10 @@ class ScaffoldState extends State { double _floatingAppBarHeight = 0.0; bool _handleScrollNotification(ScrollNotification notification) { - if (config.scrollableKey == null || config.scrollableKey == notification.scrollable.config.key) { - final double newScrollOffset = notification.scrollable.scrollOffset; + final ScrollableState scrollable = notification.scrollable; + if ((scrollable.config.scrollDirection == Axis.vertical) && + (config.scrollableKey == null || config.scrollableKey == scrollable.config.key)) { + final double newScrollOffset = scrollable.scrollOffset; setState(() { _scrollOffsetDelta = _scrollOffset - newScrollOffset; _scrollOffset = newScrollOffset;