prefer const constructor (#8292)
diff --git a/packages/flutter_tools/bin/fuchsia_builder.dart b/packages/flutter_tools/bin/fuchsia_builder.dart index 40df530..39ad9ee 100644 --- a/packages/flutter_tools/bin/fuchsia_builder.dart +++ b/packages/flutter_tools/bin/fuchsia_builder.dart
@@ -39,9 +39,9 @@ executableContext.setVariable(Logger, new StdoutLogger()); executableContext.runInZone(() { // Initialize the context with some defaults. - context.putIfAbsent(Platform, () => new LocalPlatform()); - context.putIfAbsent(FileSystem, () => new LocalFileSystem()); - context.putIfAbsent(ProcessManager, () => new LocalProcessManager()); + context.putIfAbsent(Platform, () => const LocalPlatform()); + context.putIfAbsent(FileSystem, () => const LocalFileSystem()); + context.putIfAbsent(ProcessManager, () => const LocalProcessManager()); context.putIfAbsent(Logger, () => new StdoutLogger()); context.putIfAbsent(Cache, () => new Cache()); context.putIfAbsent(Config, () => new Config());
diff --git a/packages/flutter_tools/lib/executable.dart b/packages/flutter_tools/lib/executable.dart index d759f9f..6891fc4 100644 --- a/packages/flutter_tools/lib/executable.dart +++ b/packages/flutter_tools/lib/executable.dart
@@ -102,9 +102,9 @@ // in those locations as well to see if you need a similar update there. // Seed these context entries first since others depend on them - context.putIfAbsent(Platform, () => new LocalPlatform()); - context.putIfAbsent(FileSystem, () => new LocalFileSystem()); - context.putIfAbsent(ProcessManager, () => new LocalProcessManager()); + context.putIfAbsent(Platform, () => const LocalPlatform()); + context.putIfAbsent(FileSystem, () => const LocalFileSystem()); + context.putIfAbsent(ProcessManager, () => const LocalProcessManager()); context.putIfAbsent(Logger, () => platform.isWindows ? new WindowsStdoutLogger() : new StdoutLogger()); context.putIfAbsent(Config, () => new Config());
diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index ff6389f..f4f565f 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart
@@ -459,7 +459,7 @@ 'shell', 'am', 'broadcast', '-a', 'io.flutter.view.DISCOVER' ])); - return new Future<List<DiscoveredApp>>.delayed(new Duration(seconds: 1), () { + return new Future<List<DiscoveredApp>>.delayed(const Duration(seconds: 1), () { logs.cancel(); return result; });
diff --git a/packages/flutter_tools/lib/src/base/config.dart b/packages/flutter_tools/lib/src/base/config.dart index 7d38c2e..729bdd5 100644 --- a/packages/flutter_tools/lib/src/base/config.dart +++ b/packages/flutter_tools/lib/src/base/config.dart
@@ -37,7 +37,7 @@ } void _flushValues() { - String json = new JsonEncoder.withIndent(' ').convert(_values); + String json = const JsonEncoder.withIndent(' ').convert(_values); json = '$json\n'; _configFile.writeAsStringSync(json); }
diff --git a/packages/flutter_tools/lib/src/base/logger.dart b/packages/flutter_tools/lib/src/base/logger.dart index d413ac9..9f4644c 100644 --- a/packages/flutter_tools/lib/src/base/logger.dart +++ b/packages/flutter_tools/lib/src/base/logger.dart
@@ -295,7 +295,7 @@ stdout.write('${message.padRight(52)} '); stdout.write('${_progress[0]}'); - timer = new Timer.periodic(new Duration(milliseconds: 100), _callback); + timer = new Timer.periodic(const Duration(milliseconds: 100), _callback); } static final List<String> _progress = <String>['-', r'\', '|', r'/', '-', r'\', '|', '/'];
diff --git a/packages/flutter_tools/lib/src/base/process_manager.dart b/packages/flutter_tools/lib/src/base/process_manager.dart index 382ef86..ecf8fca 100644 --- a/packages/flutter_tools/lib/src/base/process_manager.dart +++ b/packages/flutter_tools/lib/src/base/process_manager.dart
@@ -29,7 +29,7 @@ /// subdirectory. void enableRecordingProcessManager(String location) { Directory dir = getRecordingSink(location, _kRecordingType); - ProcessManager delegate = new LocalProcessManager(); + ProcessManager delegate = const LocalProcessManager(); RecordingProcessManager manager = new RecordingProcessManager(delegate, dir); addShutdownHook(() => manager.flush(finishRunningProcesses: true)); context.setVariable(ProcessManager, manager);
diff --git a/packages/flutter_tools/lib/src/base/utils.dart b/packages/flutter_tools/lib/src/base/utils.dart index 7fe223b..608fa7e 100644 --- a/packages/flutter_tools/lib/src/base/utils.dart +++ b/packages/flutter_tools/lib/src/base/utils.dart
@@ -73,7 +73,7 @@ } String toPrettyJson(Object jsonable) { - return new JsonEncoder.withIndent(' ').convert(jsonable) + '\n'; + return const JsonEncoder.withIndent(' ').convert(jsonable) + '\n'; } /// Return a String - with units - for the size in MB of the given number of bytes.
diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index eb8ae7a..5309be1 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart
@@ -464,7 +464,7 @@ if (app == null) throw "app '$appId' not found"; - return app.stop().timeout(new Duration(seconds: 5)).then<bool>((_) { + return app.stop().timeout(const Duration(seconds: 5)).then<bool>((_) { return true; }).catchError((dynamic error) { _sendAppEvent(app, 'log', <String, dynamic>{ 'log': '$error', 'error': true });
diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart index 292bbc2..3f67022 100644 --- a/packages/flutter_tools/lib/src/commands/test.dart +++ b/packages/flutter_tools/lib/src/commands/test.dart
@@ -97,7 +97,7 @@ Future<bool> _collectCoverageData(CoverageCollector collector, { bool mergeCoverageData: false }) async { Status status = logger.startProgress('Collecting coverage information...'); String coverageData = await collector.finalizeCoverage( - timeout: new Duration(seconds: 30), + timeout: const Duration(seconds: 30), ); status.stop(); printTrace('coverage information collection complete');
diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart index ebf23f3..4da5284 100644 --- a/packages/flutter_tools/lib/src/ios/simulators.dart +++ b/packages/flutter_tools/lib/src/ios/simulators.dart
@@ -83,7 +83,7 @@ connected = _isAnyConnected(); if (!connected) { printStatus('Still waiting for iOS Simulator to boot...'); - await new Future<Null>.delayed(new Duration(seconds: 1)); + await new Future<Null>.delayed(const Duration(seconds: 1)); } attempted++; }
diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 2450bd5..6bda33f 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart
@@ -218,7 +218,7 @@ for (int i = 0; vmService.vm.mainView == null && i < 5; i++) { // If the VM doesn't yet have a view, wait for one to show up. printTrace('Waiting for Flutter view'); - await new Future<Null>.delayed(new Duration(seconds: 1)); + await new Future<Null>.delayed(const Duration(seconds: 1)); await vmService.vm.refreshViews(); } currentView = vmService.vm.mainView; @@ -354,7 +354,7 @@ if ((currentView != null) && (currentView.uiIsolate != null)) { // TODO(johnmccutchan): Wait for the exit command to complete. currentView.uiIsolate.flutterExit(); - await new Future<Null>.delayed(new Duration(milliseconds: 100)); + await new Future<Null>.delayed(const Duration(milliseconds: 100)); } } appFinished();
diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index b731c32..570e762 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart
@@ -314,7 +314,7 @@ if (_devFS != null) { // Cleanup the devFS; don't wait indefinitely, and ignore any errors. await _devFS.destroy() - .timeout(new Duration(milliseconds: 250)) + .timeout(const Duration(milliseconds: 250)) .catchError((dynamic error) { printTrace('$error'); });
diff --git a/packages/flutter_tools/lib/src/usage.dart b/packages/flutter_tools/lib/src/usage.dart index ba4301d..2f4b5ec 100644 --- a/packages/flutter_tools/lib/src/usage.dart +++ b/packages/flutter_tools/lib/src/usage.dart
@@ -96,7 +96,7 @@ // TODO(devoncarew): This may delay tool exit and could cause some analytics // events to not be reported. Perhaps we could send the analytics pings // out-of-process from flutter_tools? - await _analytics.waitForLastPing(timeout: new Duration(milliseconds: 250)); + await _analytics.waitForLastPing(timeout: const Duration(milliseconds: 250)); } void printUsage() {
diff --git a/packages/flutter_tools/test/asset_bundle_test.dart b/packages/flutter_tools/test/asset_bundle_test.dart index 98409bf..bc72096 100644 --- a/packages/flutter_tools/test/asset_bundle_test.dart +++ b/packages/flutter_tools/test/asset_bundle_test.dart
@@ -10,7 +10,7 @@ void main() { // Create a temporary directory and write a single file into it. - FileSystem fs = new LocalFileSystem(); + FileSystem fs = const LocalFileSystem(); Directory tempDir = fs.systemTempDirectory.createTempSync(); String projectRoot = tempDir.path; String assetPath = 'banana.txt';
diff --git a/packages/flutter_tools/test/daemon_test.dart b/packages/flutter_tools/test/daemon_test.dart index 4e0a4ef..b08f121 100644 --- a/packages/flutter_tools/test/daemon_test.dart +++ b/packages/flutter_tools/test/daemon_test.dart
@@ -32,7 +32,7 @@ setUp(() { appContext = new AppContext(); notifyingLogger = new NotifyingLogger(); - appContext.setVariable(Platform, new LocalPlatform()); + appContext.setVariable(Platform, const LocalPlatform()); appContext.setVariable(Logger, notifyingLogger); appContext.setVariable(Doctor, new Doctor()); if (platform.isMacOS)
diff --git a/packages/flutter_tools/test/dependency_checker_test.dart b/packages/flutter_tools/test/dependency_checker_test.dart index 115f25d..ec38631 100644 --- a/packages/flutter_tools/test/dependency_checker_test.dart +++ b/packages/flutter_tools/test/dependency_checker_test.dart
@@ -88,7 +88,7 @@ String destinationPath = '/some/test/location'; // Copy the golden input and let the test run in an isolated temporary in-memory file system. copyDirectorySync( - new LocalFileSystem().directory(fs.path.join(dataPath, 'changed_sdk_location')), + const LocalFileSystem().directory(fs.path.join(dataPath, 'changed_sdk_location')), fs.directory(destinationPath)); fs.currentDirectory = destinationPath;
diff --git a/packages/flutter_tools/test/devfs_test.dart b/packages/flutter_tools/test/devfs_test.dart index 477d7bb..f45ebc3 100644 --- a/packages/flutter_tools/test/devfs_test.dart +++ b/packages/flutter_tools/test/devfs_test.dart
@@ -236,7 +236,7 @@ ]); expect(devFS.assetPathsToEvict, isEmpty); expect(bytes, 31); - }, timeout: new Timeout(new Duration(seconds: 5))); + }, timeout: const Timeout(const Duration(seconds: 5))); testUsingContext('delete dev file system', () async { await devFS.destroy(); @@ -340,4 +340,4 @@ fs.file(fs.path.join(_tempDirs[0].path, '.packages')).writeAsStringSync(sb.toString()); } -String _inAssetBuildDirectory(String filename) => fs.path.join(getAssetBuildDirectory(), filename); \ No newline at end of file +String _inAssetBuildDirectory(String filename) => fs.path.join(getAssetBuildDirectory(), filename);
diff --git a/packages/flutter_tools/test/src/context.dart b/packages/flutter_tools/test/src/context.dart index deb5e77..0758683 100644 --- a/packages/flutter_tools/test/src/context.dart +++ b/packages/flutter_tools/test/src/context.dart
@@ -42,9 +42,9 @@ // Initialize the test context with some default mocks. // Seed these context entries first since others depend on them - testContext.putIfAbsent(Platform, () => new LocalPlatform()); - testContext.putIfAbsent(FileSystem, () => new LocalFileSystem()); - testContext.putIfAbsent(ProcessManager, () => new LocalProcessManager()); + testContext.putIfAbsent(Platform, () => const LocalPlatform()); + testContext.putIfAbsent(FileSystem, () => const LocalFileSystem()); + testContext.putIfAbsent(ProcessManager, () => const LocalProcessManager()); testContext.putIfAbsent(Logger, () => new BufferLogger()); testContext.putIfAbsent(Config, () => new Config());