diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index e56d3864984..cc4b3aa698e 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -22,9 +22,18 @@ class StockHome extends StatefulComponent { class StockHomeState extends State { final GlobalKey _scaffoldKey = new GlobalKey(); - final TabBarSelection _tabBarSelection = new TabBarSelection(); bool _isSearching = false; String _searchQuery; + TabBarSelection _tabBarSelection; + + void initState() { + super.initState(); + _tabBarSelection = PageStorage.of(context)?.readState(context); + if (_tabBarSelection == null) { + _tabBarSelection = new TabBarSelection(); + PageStorage.of(context)?.writeState(context, _tabBarSelection); + } + } void _handleSearchBegin() { ModalRoute.of(context).addLocalHistoryEntry(new LocalHistoryEntry(