Updated the use of Navigator to track API changes in the Flutter.
Now synced to the latest Flutter version.

Change-Id: Idec90c7342a4e0649e6a9a84f5332d3a40c72b0f
diff --git a/dart/FLUTTER_VERSION b/dart/FLUTTER_VERSION
index 7c3d0f3..774d413 100644
--- a/dart/FLUTTER_VERSION
+++ b/dart/FLUTTER_VERSION
@@ -1 +1 @@
-ee8c0ad30d60ac965c243f7bf982527736d54cd8
+c13fe8eb5a67d550d2b9742831aa7d15dc80f649
diff --git a/dart/lib/components/askquestion.dart b/dart/lib/components/askquestion.dart
index 0dad214..24c2fbf 100644
--- a/dart/lib/components/askquestion.dart
+++ b/dart/lib/components/askquestion.dart
@@ -34,7 +34,7 @@
 
       // TODO(aghassemi): Add a 'Question submitted.' toast on the parent page.
       // Blocked on https://github.com/flutter/flutter/issues/608
-      Navigator.of(context).pop();
+      Navigator.pop(context);
     });
 
     var view = new Row([input], alignItems: FlexAlignItems.stretch);
@@ -43,7 +43,7 @@
         toolBar: new ToolBar(
             left: new IconButton(
                 icon: 'navigation/arrow_back',
-                onPressed: () => Navigator.of(context).pop()),
+                onPressed: () => Navigator.pop(context)),
             center: new Text('Ask a question')),
         body: new Material(child: view));
   }
diff --git a/dart/lib/components/deckgrid.dart b/dart/lib/components/deckgrid.dart
index 9893e12..0874c53 100644
--- a/dart/lib/components/deckgrid.dart
+++ b/dart/lib/components/deckgrid.dart
@@ -86,8 +86,10 @@
     subtitleWidget = stopWrapping(subtitleWidget);
     var footer = _buildBoxFooter(deckData.name, subtitleWidget);
     var box = _buildCard(deckData.key, [thumbnail, footer], () {
-      Navigator.of(context).push(new MaterialPageRoute(
-          builder: (context) => new SlideListPage(deckData.key)));
+      Navigator.push(
+          context,
+          new MaterialPageRoute(
+              builder: (context) => new SlideListPage(deckData.key)));
     });
 
     return box;
@@ -116,12 +118,16 @@
             _scaffoldKey, 'Joined presentation ${presentationData.deck.name}.');
 
         // Push slides list page first before navigating to the slideshow.
-        Navigator.of(context).push(new MaterialPageRoute(
-            builder: (context) =>
-                new SlideListPage(presentationData.deck.key)));
-        Navigator.of(context).push(new MaterialPageRoute(
-            builder: (context) =>
-                new SlideshowPage(presentationData.deck.key)));
+        Navigator.push(
+            context,
+            new MaterialPageRoute(
+                builder: (context) =>
+                    new SlideListPage(presentationData.deck.key)));
+        Navigator.push(
+            context,
+            new MaterialPageRoute(
+                builder: (context) =>
+                    new SlideshowPage(presentationData.deck.key)));
       } catch (e) {
         toast.error(_scaffoldKey,
             'Failed to start presentation ${presentationData.deck.name}.', e);
diff --git a/dart/lib/components/questionlist.dart b/dart/lib/components/questionlist.dart
index 7ddcabc..121d779 100644
--- a/dart/lib/components/questionlist.dart
+++ b/dart/lib/components/questionlist.dart
@@ -40,7 +40,7 @@
         toolBar: new ToolBar(
             left: new IconButton(
                 icon: 'navigation/arrow_back',
-                onPressed: () => Navigator.of(context).pop()),
+                onPressed: () => Navigator.pop(context)),
             center: new Text('Answer questions')),
         body: new Material(
             child: new QuestionList(_deckId, presentationState,
@@ -101,7 +101,7 @@
 
     Widget handoff = new GestureDetector(onTap: () async {
       await _appActions.setDriver(_deckId, q.questioner);
-      Navigator.of(context).pop();
+      Navigator.pop(context);
     }, child: new Container(child: new Text('HAND OFF')));
 
     Widget actions = new Container(
diff --git a/dart/lib/components/slidelist.dart b/dart/lib/components/slidelist.dart
index b030704..86d0ac6 100644
--- a/dart/lib/components/slidelist.dart
+++ b/dart/lib/components/slidelist.dart
@@ -31,7 +31,7 @@
         toolBar: new ToolBar(
             left: new IconButton(
                 icon: 'navigation/arrow_back',
-                onPressed: () => Navigator.of(context).pop()),
+                onPressed: () => Navigator.pop(context)),
             center: new Text(deckState.deck.name)),
         floatingActionButton: _buildPresentFab(context, appState, appActions),
         body: new Material(child: new SlideList(_deckId, slides, appActions)));
@@ -54,8 +54,10 @@
         await appActions.startPresentation(_deckId);
         toast.info(_scaffoldKey, 'Presentation started.');
 
-        Navigator.of(context).push(new MaterialPageRoute(
-            builder: (context) => new SlideshowPage(_deckId)));
+        Navigator.push(
+            context,
+            new MaterialPageRoute(
+                builder: (context) => new SlideshowPage(_deckId)));
       } catch (e) {
         toast.error(_scaffoldKey, 'Failed to start presentation.', e);
       }
@@ -70,7 +72,6 @@
   SlideList(this._deckId, this._slides, this._appActions);
 
   Widget build(BuildContext context) {
-    NavigatorState navigator = Navigator.of(context);
     return new ScrollableList(
         itemExtent: style.Size.listHeight,
         items: _slides,
@@ -78,8 +79,10 @@
             _buildSlide(context, _deckId, index, value, onTap: () {
               _appActions.setCurrSlideNum(_deckId, index);
 
-              navigator.push(new MaterialPageRoute(
-                  builder: (context) => new SlideshowPage(_deckId)));
+              Navigator.push(
+                  context,
+                  new MaterialPageRoute(
+                      builder: (context) => new SlideshowPage(_deckId)));
             }));
   }
 }
diff --git a/dart/lib/components/slideshow.dart b/dart/lib/components/slideshow.dart
index ce06c28..fee3b05 100644
--- a/dart/lib/components/slideshow.dart
+++ b/dart/lib/components/slideshow.dart
@@ -40,14 +40,11 @@
   AppActions _appActions;
   AppState _appState;
   DeckState _deckState;
-  NavigatorState _navigator;
   int _currSlideNum;
 
   SlideShow(this._appActions, this._appState, this._deckState);
 
   Widget build(BuildContext context) {
-    _navigator = Navigator.of(context);
-
     if (_deckState.slides.length == 0) {
       // TODO(aghassemi): Proper error page with navigation back to main view.
       return new Text('No slide to show.');
@@ -82,8 +79,8 @@
   }
 
   Widget _buildPortraitLayout(BuildContext context) {
-    var image = new Flexible(child: _buildImage(), flex: 5);
-    var actions = new Flexible(child: _buildActions(), flex: 1);
+    var image = new Flexible(child: _buildImage(context), flex: 5);
+    var actions = new Flexible(child: _buildActions(context), flex: 1);
     var notes = new Flexible(child: _buildNotes(), flex: 3);
     var nav = new Flexible(child: new Row(_buildThumbnailNavs()), flex: 3);
 
@@ -103,8 +100,8 @@
     var notes = new Flexible(child: _buildNotes(), flex: 5);
     var nav = new Flexible(child: new Column(_buildThumbnailNavs()), flex: 8);
 
-    var image = new Flexible(child: _buildImage(), flex: 11);
-    var actions = new Flexible(child: _buildActions(), flex: 2);
+    var image = new Flexible(child: _buildImage(context), flex: 11);
+    var actions = new Flexible(child: _buildActions(context), flex: 2);
 
     var notesAndNavColumn = new Flexible(
         child: new Column([notes, nav], alignItems: FlexAlignItems.stretch),
@@ -132,7 +129,7 @@
     ];
   }
 
-  Widget _buildImage() {
+  Widget _buildImage(BuildContext context) {
     var provider = imageProvider.getSlideImage(
         _deckState.deck.key, _deckState.slides[_currSlideNum]);
 
@@ -142,9 +139,11 @@
     if (_deckState.presentation == null ||
         !_deckState.presentation.isDriving(_appState.user)) {
       image = new InkWell(child: image, onTap: () {
-        _navigator.push(new MaterialPageRoute(
-            builder: (context) =>
-                new SlideshowImmersivePage(_deckState.deck.key)));
+        Navigator.push(
+            context,
+            new MaterialPageRoute(
+                builder: (context) =>
+                    new SlideshowImmersivePage(_deckState.deck.key)));
       });
     }
 
@@ -194,7 +193,7 @@
     return new Flexible(child: container, flex: 1);
   }
 
-  Widget _buildActions() {
+  Widget _buildActions(BuildContext context) {
     // It collects a list of action widgets for the action bar and fabs.
     // Left contains items that are in-line on the left side of the UI.
     // Right contains the FABs that hover over the right side of the UI.
@@ -202,8 +201,8 @@
     List<Widget> right = [];
 
     _buildActions_prev(left, right);
-    _buildActions_slidelist(left, right);
-    _buildActions_question(left, right);
+    _buildActions_slidelist(left, right, context);
+    _buildActions_question(left, right, context);
     _buildActions_next(left, right);
     _buildActions_followPresentation(left, right);
 
@@ -222,15 +221,17 @@
     left.add(prev);
   }
 
-  void _buildActions_slidelist(List<Widget> left, List<Widget> right) {
+  void _buildActions_slidelist(
+      List<Widget> left, List<Widget> right, BuildContext context) {
     var slideList =
         new InkWell(child: new Icon(icon: 'maps/layers'), onTap: () {
-      _navigator.pop();
+      Navigator.pop(context);
     });
     left.add(slideList);
   }
 
-  void _buildActions_question(List<Widget> left, List<Widget> right) {
+  void _buildActions_question(
+      List<Widget> left, List<Widget> right, BuildContext context) {
     if (_deckState.presentation == null) {
       return;
     }
@@ -249,8 +250,11 @@
 
       var questions = new InkWell(
           child: new Icon(icon: 'communication/live_help'), onTap: () {
-        _navigator.push(new MaterialPageRoute(
-            builder: (context) => new QuestionListPage(_deckState.deck.key)));
+        Navigator.push(
+            context,
+            new MaterialPageRoute(
+                builder: (context) =>
+                    new QuestionListPage(_deckState.deck.key)));
       });
 
       left.add(questions);
@@ -263,7 +267,7 @@
 
       var askQuestion = new InkWell(
           child: new Icon(icon: 'communication/live_help'), onTap: () {
-        _navigator.push(route);
+        Navigator.push(context, route);
       });
       left.add(askQuestion);
     }
diff --git a/dart/lib/main.dart b/dart/lib/main.dart
index ab0ed02..cb32ae3 100644
--- a/dart/lib/main.dart
+++ b/dart/lib/main.dart
@@ -26,7 +26,7 @@
 
 class LandingPage extends StatelessComponent {
   Widget build(BuildContext context) {
-    _navigator = Navigator.of(context);
+    _navigator = context.ancestorStateOfType(NavigatorState);
     return new DeckGridPage();
   }
 }
@@ -40,9 +40,17 @@
 
 void _initBackButtonHandler() {
   backButtonUtil.onBackButton(() {
-    if (_navigator != null && _navigator.hasPreviousRoute) {
-      _navigator.pop();
-      return true;
+    if (_navigator != null) {
+      bool returnValue;
+      _navigator.openTransaction((NavigatorTransaction transaction) {
+        returnValue = transaction.pop(null);
+        if (!returnValue) {
+          // pop() returns false when we popped the top-level route.
+          // To stay on the landing page, we re-push its route.
+          transaction.pushNamed('/');
+        }
+      });
+      return returnValue;
     }
 
     // Tell the app to exit.
diff --git a/dart/pubspec.lock b/dart/pubspec.lock
index 979700a..a18ad55 100644
--- a/dart/pubspec.lock
+++ b/dart/pubspec.lock
@@ -4,7 +4,7 @@
   analyzer:
     description: analyzer
     source: hosted
-    version: "0.26.2+1"
+    version: "0.26.3"
   archive:
     description: archive
     source: hosted
@@ -46,7 +46,7 @@
   collection:
     description: collection
     source: hosted
-    version: "1.1.3"
+    version: "1.2.0"
   convert:
     description: convert
     source: hosted
@@ -120,23 +120,23 @@
   mojo:
     description: mojo
     source: hosted
-    version: "0.4.3"
+    version: "0.4.5"
   mojo_apptest:
     description: mojo_apptest
     source: hosted
-    version: "0.2.8"
+    version: "0.2.9"
   mojo_sdk:
     description: mojo_sdk
     source: hosted
-    version: "0.2.2"
+    version: "0.2.4"
   mojo_services:
     description: mojo_services
     source: hosted
-    version: "0.4.5"
+    version: "0.4.7"
   mojom:
     description: mojom
     source: hosted
-    version: "0.2.8"
+    version: "0.2.9"
   mustache4dart:
     description: mustache4dart
     source: hosted
@@ -154,7 +154,7 @@
   path:
     description: path
     source: hosted
-    version: "1.3.7"
+    version: "1.3.9"
   petitparser:
     description: petitparser
     source: hosted
@@ -186,11 +186,11 @@
   sky_engine:
     description: sky_engine
     source: hosted
-    version: "0.0.58"
+    version: "0.0.65"
   sky_services:
     description: sky_services
     source: hosted
-    version: "0.0.58"
+    version: "0.0.65"
   source_map_stack_trace:
     description: source_map_stack_trace
     source: hosted
@@ -218,7 +218,7 @@
   test:
     description: test
     source: hosted
-    version: "0.12.5+2"
+    version: "0.12.6"
   typed_data:
     description: typed_data
     source: hosted
@@ -234,7 +234,7 @@
   v23discovery:
     description: v23discovery
     source: hosted
-    version: "0.0.5"
+    version: "0.0.6"
   vector_math:
     description: vector_math
     source: hosted