Merge pull request #1777 from vlidholt/master

Fitness demo, initial version
diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart
index 53e47e4..0311acf 100644
--- a/packages/flutter/lib/src/widgets/framework.dart
+++ b/packages/flutter/lib/src/widgets/framework.dart
@@ -274,7 +274,7 @@
   /// override this to return a new instance of the State class associated with
   /// this StatefulComponent class, like this:
   ///
-  ///   MyState createState() => new MyState(this);
+  ///   _MyState createState() => new _MyState();
   State createState();
 }
 
diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart
index 6b439eb..f233911 100644
--- a/packages/flutter_tools/lib/src/commands/create.dart
+++ b/packages/flutter_tools/lib/src/commands/create.dart
@@ -12,7 +12,7 @@
 import '../android/android.dart' as android;
 import '../artifacts.dart';
 import '../base/globals.dart';
-import '../base/process.dart';
+import '../dart/pub.dart';
 import 'ios.dart';
 
 class CreateCommand extends Command {
@@ -70,39 +70,6 @@
     printStatus(message);
     return 0;
   }
-
-  Future<int> pubGet({
-    String directory: '',
-    bool skipIfAbsent: false
-  }) async {
-    File pubSpecYaml = new File(path.join(directory, 'pubspec.yaml'));
-    File pubSpecLock = new File(path.join(directory, 'pubspec.lock'));
-    File dotPackages = new File(path.join(directory, '.packages'));
-
-    if (!pubSpecYaml.existsSync()) {
-      if (skipIfAbsent)
-        return 0;
-      printError('$directory: no pubspec.yaml found');
-      return 1;
-    }
-
-    if (!pubSpecLock.existsSync() || pubSpecYaml.lastModifiedSync().isAfter(pubSpecLock.lastModifiedSync())) {
-      printStatus("Running 'pub get' in '$directory'...");
-      int code = await runCommandAndStreamOutput(
-        <String>[sdkBinaryName('pub'), '--verbosity=warning', 'get'],
-        workingDirectory: directory
-      );
-      if (code != 0)
-        return code;
-    }
-
-    if ((pubSpecLock.existsSync() && pubSpecLock.lastModifiedSync().isAfter(pubSpecYaml.lastModifiedSync())) &&
-        (dotPackages.existsSync() && dotPackages.lastModifiedSync().isAfter(pubSpecYaml.lastModifiedSync())))
-      return 0;
-
-    printError('$directory: pubspec.yaml, pubspec.lock, and .packages are in an inconsistent state');
-    return 1;
-  }
 }
 
 abstract class Template {
diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart
index 7759cd6..1ae20a5 100644
--- a/packages/flutter_tools/lib/src/commands/run.dart
+++ b/packages/flutter_tools/lib/src/commands/run.dart
@@ -11,6 +11,7 @@
 import '../base/common.dart';
 import '../base/globals.dart';
 import '../build_configuration.dart';
+import '../dart/pub.dart';
 import '../device.dart';
 import '../flx.dart';
 import '../runner/flutter_command.dart';
@@ -68,12 +69,22 @@
         defaultsTo: false,
         negatable: false,
         help: 'Start in a paused mode and wait for a debugger to connect.');
+    argParser.addFlag('pub',
+        defaultsTo: true,
+        help: 'Whether to run "pub get" before running the app.');
     argParser.addOption('debug-port',
         defaultsTo: observatoryDefaultPort.toString(),
         help: 'Listen to the given port for a debug connection.');
   }
 
   @override
+  Future<int> run() async {
+    if (argResults['pub'])
+      await pubGet();
+    return await super.run();
+  }
+
+  @override
   Future<int> runInProject() async {
     printTrace('Downloading toolchain.');
 
diff --git a/packages/flutter_tools/lib/src/dart/pub.dart b/packages/flutter_tools/lib/src/dart/pub.dart
new file mode 100644
index 0000000..1856561
--- /dev/null
+++ b/packages/flutter_tools/lib/src/dart/pub.dart
@@ -0,0 +1,47 @@
+// Copyright 2016 The Chromium 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 'dart:async';
+import 'dart:io';
+
+import 'package:path/path.dart' as path;
+
+import '../base/globals.dart';
+import '../base/process.dart';
+
+Future<int> pubGet({
+  String directory,
+  bool skipIfAbsent: false
+}) async {
+  if (directory == null)
+    directory = Directory.current.path;
+
+  File pubSpecYaml = new File(path.join(directory, 'pubspec.yaml'));
+  File pubSpecLock = new File(path.join(directory, 'pubspec.lock'));
+  File dotPackages = new File(path.join(directory, '.packages'));
+
+  if (!pubSpecYaml.existsSync()) {
+    if (skipIfAbsent)
+      return 0;
+    printError('$directory: no pubspec.yaml found');
+    return 1;
+  }
+
+  if (!pubSpecLock.existsSync() || pubSpecYaml.lastModifiedSync().isAfter(pubSpecLock.lastModifiedSync())) {
+    printStatus("Running 'pub get' in '$directory'...");
+    int code = await runCommandAndStreamOutput(
+      <String>[sdkBinaryName('pub'), '--verbosity=warning', 'get'],
+      workingDirectory: directory
+    );
+    if (code != 0)
+      return code;
+  }
+
+  if ((pubSpecLock.existsSync() && pubSpecLock.lastModifiedSync().isAfter(pubSpecYaml.lastModifiedSync())) &&
+      (dotPackages.existsSync() && dotPackages.lastModifiedSync().isAfter(pubSpecYaml.lastModifiedSync())))
+    return 0;
+
+  printError('$directory: pubspec.yaml, pubspec.lock, and .packages are in an inconsistent state');
+  return 1;
+}