Update flutter_tools to use package:file throughout (#7385)

This removes direct file access from within flutter_tools
in favor of using `package:file` via a `FileSystem` that's
accessed via the `ApplicationContext`.

This lays the groundwork for us to be able to easily swap
out the underlying file system when running Flutter tools,
which will be used to provide a record/replay file system,
analogous to what we have for process invocations.
diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart
index 3d21f16..83f3e7d 100644
--- a/packages/flutter_tools/lib/src/commands/create.dart
+++ b/packages/flutter_tools/lib/src/commands/create.dart
@@ -3,12 +3,12 @@
 // found in the LICENSE file.
 
 import 'dart:async';
-import 'dart:io';
 
 import 'package:path/path.dart' as path;
 
 import '../android/android.dart' as android;
 import '../base/common.dart';
+import '../base/file_system.dart';
 import '../base/utils.dart';
 import '../cache.dart';
 import '../dart/pub.dart';
@@ -72,14 +72,14 @@
 
     String flutterPackagesDirectory = path.join(flutterRoot, 'packages');
     String flutterPackagePath = path.join(flutterPackagesDirectory, 'flutter');
-    if (!FileSystemEntity.isFileSync(path.join(flutterPackagePath, 'pubspec.yaml')))
+    if (!fs.isFileSync(path.join(flutterPackagePath, 'pubspec.yaml')))
       throwToolExit('Unable to find package:flutter in $flutterPackagePath', exitCode: 2);
 
     String flutterDriverPackagePath = path.join(flutterRoot, 'packages', 'flutter_driver');
-    if (!FileSystemEntity.isFileSync(path.join(flutterDriverPackagePath, 'pubspec.yaml')))
+    if (!fs.isFileSync(path.join(flutterDriverPackagePath, 'pubspec.yaml')))
       throwToolExit('Unable to find package:flutter_driver in $flutterDriverPackagePath', exitCode: 2);
 
-    Directory projectDir = new Directory(argResults.rest.first);
+    Directory projectDir = fs.directory(argResults.rest.first);
     String dirPath = path.normalize(projectDir.absolute.path);
     String relativePath = path.relative(dirPath);
     String projectName = _normalizeProjectName(path.basename(dirPath));
@@ -139,7 +139,7 @@
 
   int _renderTemplates(String projectName, String projectDescription, String dirPath,
       String flutterPackagesDirectory, { bool renderDriverTest: false }) {
-    new Directory(dirPath).createSync(recursive: true);
+    fs.directory(dirPath).createSync(recursive: true);
 
     flutterPackagesDirectory = path.normalize(flutterPackagesDirectory);
     flutterPackagesDirectory = _relativePath(from: dirPath, to: flutterPackagesDirectory);
@@ -161,14 +161,14 @@
 
     Template createTemplate = new Template.fromName('create');
     fileCount += createTemplate.render(
-      new Directory(dirPath),
+      fs.directory(dirPath),
       templateContext, overwriteExisting: false,
       projectName: projectName
     );
 
     if (renderDriverTest) {
       Template driverTemplate = new Template.fromName('driver');
-      fileCount += driverTemplate.render(new Directory(path.join(dirPath, 'test_driver')),
+      fileCount += driverTemplate.render(fs.directory(path.join(dirPath, 'test_driver')),
           templateContext, overwriteExisting: false);
     }
 
@@ -234,7 +234,7 @@
       "Target directory '$dirPath' is within the Flutter SDK at '$flutterRoot'.";
   }
 
-  FileSystemEntityType type = FileSystemEntity.typeSync(dirPath);
+  FileSystemEntityType type = fs.typeSync(dirPath);
 
   if (type != FileSystemEntityType.NOT_FOUND) {
     switch(type) {
@@ -253,7 +253,7 @@
 String _relativePath({ String from, String to }) {
   String result = path.relative(to, from: from);
   // `path.relative()` doesn't always return a correct result: dart-lang/path#12.
-  if (FileSystemEntity.isDirectorySync(path.join(from, result)))
+  if (fs.isDirectorySync(path.join(from, result)))
     return result;
   return to;
 }