diff --git a/examples/stocks2/lib/stock_app.dart b/examples/stocks2/lib/stock_app.dart index 1c450b0268..1586b17355 100644 --- a/examples/stocks2/lib/stock_app.dart +++ b/examples/stocks2/lib/stock_app.dart @@ -14,19 +14,24 @@ class StocksApp extends App { StocksApp({ RenderView renderViewOverride }) : super(renderViewOverride: renderViewOverride); + NavigationState _navState = new NavigationState([ + new Route(name: '/', builder: (navigator) => new StockHome(navigator)), + new Route(name: '/settings', builder: (navigator) => new StockSettings(navigator)), + ]); + + void onBack() { + if (_navState.hasPrevious()) { + setState(() { + _navState.pop(); + }); + return; + } + print ("Should exit app here"); + // TODO(jackson): Need a way to invoke default back behavior here + } + Widget build() { - return new Navigator( - routes: [ - new Route( - name: '/', - builder: (navigator) => new StockHome(navigator) - ), - new Route( - name: '/settings', - builder: (navigator) => new StockSettings(navigator) - ), - ] - ); + return new Navigator(_navState); } } diff --git a/examples/widgets/navigation.dart b/examples/widgets/navigation.dart index ca81a4fbd7..82e81f8502 100644 --- a/examples/widgets/navigation.dart +++ b/examples/widgets/navigation.dart @@ -65,8 +65,10 @@ List routes = [ ]; class NavigationExampleApp extends App { + NavigationState _navState = new NavigationState(routes); + Widget build() { - return new Flex([new Navigator(routes: routes)]); + return new Flex([new Navigator(_navState)]); } }