croupier: Upgrade Flutter and Drawer

Since the recent flutter changes include the Drawer changes, I was able
to remove the DebugRoute.

Closes https://github.com/vanadium/issues/issues/957

Change-Id: I42d603f0940c730917a81d47f71a954a6549cf4b
diff --git a/lib/components/croupier_settings.dart b/lib/components/croupier_settings.dart
index fc218c5..93181a2 100644
--- a/lib/components/croupier_settings.dart
+++ b/lib/components/croupier_settings.dart
@@ -74,7 +74,7 @@
     return new ToolBar(
         left: new IconButton(
             icon: "navigation/arrow_back",
-            onPressed: () => Navigator.of(context).pop()),
+            onPressed: () => Navigator.pop(context)),
         center: new Text("Settings"));
   }
 
@@ -107,7 +107,6 @@
     var capType = _capitalize(type);
 
     Dialog dialog;
-    NavigatorState navigator = Navigator.of(context);
 
     switch (dialogTypes[type]) {
       case DialogType.Text:
@@ -121,10 +120,10 @@
                 onChanged: _makeHandleChanged(type)),
             actions: [
               new FlatButton(child: new Text('CANCEL'), onPressed: () {
-                navigator.pop();
+                Navigator.pop(context);
               }),
               new FlatButton(child: new Text('SAVE'), onPressed: () {
-                navigator.pop(_tempData[type]);
+                Navigator.pop(context);
               }),
             ]);
         break;
@@ -145,7 +144,7 @@
           flexColors.add(_makeColoredRectangle(c, "", () {
             // TODO(alexfandrianto): Remove this hack-y subtraction once the
             // Dart + Android issue with int.parse is fixed.
-            navigator.pop("${c - 0xcf000000}");
+            Navigator.pop(context, "${c - 0xcf000000}");
           }));
         }
 
@@ -154,7 +153,7 @@
             content: new Grid(flexColors, maxChildExtent: 75.0),
             actions: [
               new FlatButton(child: new Text('CANCEL'), onPressed: () {
-                navigator.pop();
+                Navigator.pop(context);
               })
             ]);
         break;
@@ -163,7 +162,7 @@
         for (int i = 0; i < RandomSettings.avatars.length; i++) {
           String avatar = RandomSettings.avatars[i];
           flexAvatars.add(_makeImageButton(avatar, () {
-            navigator.pop(avatar);
+            Navigator.pop(context, avatar);
           }));
         }
 
@@ -172,7 +171,7 @@
             content: new Grid(flexAvatars, maxChildExtent: 75.0),
             actions: [
               new FlatButton(child: new Text('CANCEL'), onPressed: () {
-                navigator.pop();
+                Navigator.pop(context);
               })
             ]);
         break;
diff --git a/lib/components/debug_route.dart b/lib/components/debug_route.dart
deleted file mode 100644
index a0551ed..0000000
--- a/lib/components/debug_route.dart
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2015 The Vanadium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-import 'package:flutter/material.dart';
-
-import '../logic/croupier.dart' show Croupier;
-import '../styles/common.dart' as style;
-
-// TODO(alexfandrianto): Remove this file once Flutter alpha branch is updated
-// and this route's Switch can be placed within the DrawerItem.
-// https://github.com/vanadium/issues/issues/957
-class DebugRoute extends StatefulComponent {
-  final Croupier croupier;
-
-  DebugRoute(this.croupier);
-
-  DebugRouteState createState() => new DebugRouteState();
-}
-
-class DebugRouteState extends State<DebugRoute> {
-  Widget build(BuildContext context) {
-    return new Scaffold(
-        toolBar: _buildToolBar(), body: _buildDebugPane(context));
-  }
-
-  Widget _buildToolBar() {
-    return new ToolBar(
-        left: new IconButton(
-            icon: "navigation/arrow_back",
-            onPressed: () => Navigator.of(context).pop()),
-        center: new Text("Debug Settings"));
-  }
-
-  Widget _buildDebugPane(BuildContext context) {
-    return new Row([
-      new Text('Debug Mode', style: style.Text.titleStyle),
-      new Switch(value: config.croupier.debugMode, onChanged: _handleDebugMode),
-    ],
-        justifyContent: FlexJustifyContent.spaceAround,
-        alignItems: FlexAlignItems.start);
-  }
-
-  void _handleDebugMode(bool value) {
-    print("new value is ${value}. Old is ${config.croupier.debugMode}");
-    setState(() {
-      config.croupier.debugMode = value;
-      if (config.croupier.game != null) {
-        config.croupier.game.debugMode = value;
-      }
-    });
-  }
-}
diff --git a/lib/components/game.dart b/lib/components/game.dart
index b9f844e..c726f92 100644
--- a/lib/components/game.dart
+++ b/lib/components/game.dart
@@ -7,7 +7,7 @@
 import 'dart:math' as math;
 import 'dart:async';
 
-import 'package:flutter/animation.dart';
+import 'package:flutter/scheduler.dart';
 import 'package:flutter/material.dart';
 import 'package:flutter/rendering.dart';
 
@@ -142,7 +142,7 @@
   Widget buildCardAnimationLayer(List<int> visibleCardCollectionIndexes) {
     // It's possible that some cards need to be moved after this build.
     // If so, we can catch it in the next frame.
-    scheduler.requestPostFrameCallback((Duration d) {
+    scheduler.addPostFrameCallback((Duration d) {
       _cardLevelMapProcessAllVisible(visibleCardCollectionIndexes);
     });
 
diff --git a/lib/components/main_route.dart b/lib/components/main_route.dart
index 509f5d9..736561f 100644
--- a/lib/components/main_route.dart
+++ b/lib/components/main_route.dart
@@ -42,10 +42,12 @@
     return new Scaffold(
         key: _scaffoldKey,
         toolBar: new ToolBar(
-            left:
-                new IconButton(icon: "navigation/menu", onPressed: _showDrawer),
+            left: new IconButton(
+                icon: "navigation/menu",
+                onPressed: () => _scaffoldKey.currentState?.openDrawer()),
             center: new Text('Croupier')),
-        body: new Material(child: new CroupierComponent(config.croupier)));
+        body: new Material(child: new CroupierComponent(config.croupier)),
+        drawer: _buildDrawer());
   }
 
   // TODO(alexfandrianto): Can we do better than this?
@@ -68,41 +70,40 @@
     return stack;
   }
 
-  void _showDrawer() {
-    showDrawer(
-        context: context,
+  Widget _buildDrawer() {
+    return new Drawer(
         child: new Block(<Widget>[
-          new DrawerHeader(
-              child: new Text('Croupier', style: style.Text.titleStyle)),
-          new DrawerItem(
-              icon: 'action/settings',
-              // TODO(alexfandrianto): Fix the Splash Screen, and we won't need
-              // to check if settings is null here.
-              // https://github.com/vanadium/issues/issues/958
-              onPressed:
-                  config.croupier.settings != null ? _handleShowSettings : null,
-              child: new Text('Settings')),
-          // TODO(alexfandrianto): Once Flutter alpha branch is updated, this
-          // DrawerItem can have a Switch inside instead of DebugRoute.
-          // https://github.com/vanadium/issues/issues/957
-          new DrawerItem(
-              icon: 'action/build',
-              onPressed: _handleShowDebug,
-              child: new Text('Debug Mode')),
-          new DrawerItem(
-              icon: 'action/help', child: new Text('Help & Feedback'))
-        ]));
+      new DrawerHeader(
+          child: new Text('Croupier', style: style.Text.titleStyle)),
+      new DrawerItem(
+          icon: 'action/settings',
+          // TODO(alexfandrianto): Fix the Splash Screen, and we won't need
+          // to check if settings is null here.
+          // https://github.com/vanadium/issues/issues/958
+          onPressed:
+              config.croupier.settings != null ? _handleShowSettings : null,
+          child: new Text('Settings')),
+      new DrawerItem(
+          icon: 'action/build',
+          child: new Row([
+            new Text('Debug Mode'),
+            new Switch(
+                value: config.croupier.debugMode, onChanged: _handleDebugMode)
+          ], justifyContent: FlexJustifyContent.spaceBetween)),
+      new DrawerItem(icon: 'action/help', child: new Text('Help & Feedback'))
+    ]));
   }
 
   void _handleShowSettings() {
-    Navigator.of(context)
-      ..pop()
-      ..pushNamed('/settings');
+    Navigator.popAndPushNamed(context, '/settings');
   }
 
-  void _handleShowDebug() {
-    Navigator.of(context)
-      ..pop()
-      ..pushNamed('/debug');
+  void _handleDebugMode(bool value) {
+    setState(() {
+      config.croupier.debugMode = value;
+      if (config.croupier.game != null) {
+        config.croupier.game.debugMode = value;
+      }
+    });
   }
 }
diff --git a/lib/main.dart b/lib/main.dart
index 367c822..4cd2bfd 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -8,7 +8,6 @@
 import 'settings/client.dart' as settings_client;
 import 'logic/croupier.dart' show Croupier;
 import 'components/settings_route.dart' show SettingsRoute;
-import 'components/debug_route.dart' show DebugRoute;
 import 'components/main_route.dart' show MainRoute;
 import 'styles/common.dart' as style;
 
@@ -32,8 +31,7 @@
         title: 'Croupier',
         routes: <String, RouteBuilder>{
           "/": (RouteArguments args) => new MainRoute(croupier),
-          "/settings": (RouteArguments args) => new SettingsRoute(croupier),
-          "/debug": (RouteArguments args) => new DebugRoute(croupier)
+          "/settings": (RouteArguments args) => new SettingsRoute(croupier)
         },
         theme: style.theme);
   }
diff --git a/pubspec.lock b/pubspec.lock
index 99ee464..a69db82 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -68,7 +68,7 @@
       path: "../../../../../flutter/packages/flutter"
       relative: true
     source: path
-    version: "0.0.20"
+    version: "0.0.21"
   flutter_tools:
     description:
       path: "../../../../../flutter/packages/flutter_tools"
@@ -100,7 +100,7 @@
   intl:
     description: intl
     source: hosted
-    version: "0.12.4+2"
+    version: "0.12.4+3"
   logging:
     description: logging
     source: hosted
@@ -120,7 +120,7 @@
   mojo:
     description: mojo
     source: hosted
-    version: "0.4.5"
+    version: "0.4.6"
   mojo_apptest:
     description: mojo_apptest
     source: hosted
@@ -128,15 +128,15 @@
   mojo_sdk:
     description: mojo_sdk
     source: hosted
-    version: "0.2.4"
+    version: "0.2.5"
   mojo_services:
     description: mojo_services
     source: hosted
-    version: "0.4.7"
+    version: "0.4.8"
   mojom:
     description: mojom
     source: hosted
-    version: "0.2.9"
+    version: "0.2.10"
   mustache4dart:
     description: mustache4dart
     source: hosted
@@ -186,11 +186,11 @@
   sky_engine:
     description: sky_engine
     source: hosted
-    version: "0.0.65"
+    version: "0.0.69"
   sky_services:
     description: sky_services
     source: hosted
-    version: "0.0.65"
+    version: "0.0.69"
   source_map_stack_trace:
     description: source_map_stack_trace
     source: hosted
@@ -214,11 +214,11 @@
   syncbase:
     description: syncbase
     source: hosted
-    version: "0.0.22"
+    version: "0.0.23"
   test:
     description: test
     source: hosted
-    version: "0.12.5+2"
+    version: "0.12.6"
   typed_data:
     description: typed_data
     source: hosted