[flutter_tool] Remove some async file io (#38654)
diff --git a/packages/flutter_tools/lib/runner.dart b/packages/flutter_tools/lib/runner.dart index 6999486..0734f13 100644 --- a/packages/flutter_tools/lib/runner.dart +++ b/packages/flutter_tools/lib/runner.dart
@@ -179,12 +179,12 @@ buffer.writeln('```\n${await _doctorText()}```'); try { - await crashFile.writeAsString(buffer.toString()); + crashFile.writeAsStringSync(buffer.toString()); } on FileSystemException catch (_) { // Fallback to the system temporary directory. crashFile = getUniqueFile(crashFileSystem.systemTempDirectory, 'flutter', 'log'); try { - await crashFile.writeAsString(buffer.toString()); + crashFile.writeAsStringSync(buffer.toString()); } on FileSystemException catch (e) { printError('Could not write crash report to disk: $e'); printError(buffer.toString());
diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart index d121d83..737c9c7 100644 --- a/packages/flutter_tools/lib/src/asset.dart +++ b/packages/flutter_tools/lib/src/asset.dart
@@ -235,7 +235,7 @@ entries[_fontManifestJson] = DevFSStringContent(json.encode(fonts)); // TODO(ianh): Only do the following line if we've changed packages or if our LICENSE file changed - entries[_license] = await _obtainLicenses(packageMap, assetBasePath, reportPackages: reportLicensedPackages); + entries[_license] = _obtainLicenses(packageMap, assetBasePath, reportPackages: reportLicensedPackages); return 0; } @@ -325,11 +325,11 @@ final String _licenseSeparator = '\n' + ('-' * 80) + '\n'; /// Returns a DevFSContent representing the license file. -Future<DevFSContent> _obtainLicenses( +DevFSContent _obtainLicenses( PackageMap packageMap, String assetBase, { bool reportPackages, -}) async { +}) { // Read the LICENSE file from each package in the .packages file, splitting // each one into each component license (so that we can de-dupe if possible). // @@ -347,30 +347,32 @@ final Set<String> allPackages = <String>{}; for (String packageName in packageMap.map.keys) { final Uri package = packageMap.map[packageName]; - if (package != null && package.scheme == 'file') { - final File file = fs.file(package.resolve('../LICENSE')); - if (file.existsSync()) { - final List<String> rawLicenses = - (await file.readAsString()).split(_licenseSeparator); - for (String rawLicense in rawLicenses) { - List<String> packageNames; - String licenseText; - if (rawLicenses.length > 1) { - final int split = rawLicense.indexOf('\n\n'); - if (split >= 0) { - packageNames = rawLicense.substring(0, split).split('\n'); - licenseText = rawLicense.substring(split + 2); - } - } - if (licenseText == null) { - packageNames = <String>[packageName]; - licenseText = rawLicense; - } - packageLicenses.putIfAbsent(licenseText, () => <String>{}) - ..addAll(packageNames); - allPackages.addAll(packageNames); + if (package == null || package.scheme != 'file') { + continue; + } + final File file = fs.file(package.resolve('../LICENSE')); + if (!file.existsSync()) { + continue; + } + final List<String> rawLicenses = + file.readAsStringSync().split(_licenseSeparator); + for (String rawLicense in rawLicenses) { + List<String> packageNames; + String licenseText; + if (rawLicenses.length > 1) { + final int split = rawLicense.indexOf('\n\n'); + if (split >= 0) { + packageNames = rawLicense.substring(0, split).split('\n'); + licenseText = rawLicense.substring(split + 2); } } + if (licenseText == null) { + packageNames = <String>[packageName]; + licenseText = rawLicense; + } + packageLicenses.putIfAbsent(licenseText, () => <String>{}) + ..addAll(packageNames); + allPackages.addAll(packageNames); } }
diff --git a/packages/flutter_tools/lib/src/base/build.dart b/packages/flutter_tools/lib/src/base/build.dart index 51bcbcc..695d869 100644 --- a/packages/flutter_tools/lib/src/base/build.dart +++ b/packages/flutter_tools/lib/src/base/build.dart
@@ -180,7 +180,7 @@ // gen_snapshot would provide an argument to do this automatically. if (platform == TargetPlatform.ios && bitcode) { final IOSink sink = fs.file('$assembly.bitcode').openWrite(); - for (String line in await fs.file(assembly).readAsLines()) { + for (String line in fs.file(assembly).readAsLinesSync()) { if (line.startsWith('.section __DWARF')) { break; } @@ -192,7 +192,7 @@ // Write path to gen_snapshot, since snapshots have to be re-generated when we roll // the Dart SDK. final String genSnapshotPath = GenSnapshot.getSnapshotterPath(snapshotType); - await outputDir.childFile('gen_snapshot.d').writeAsString('gen_snapshot.d: $genSnapshotPath\n'); + outputDir.childFile('gen_snapshot.d').writeAsStringSync('gen_snapshot.d: $genSnapshotPath\n'); // On iOS, we use Xcode to compile the snapshot into a dynamic library that the // end-developer can link into their app. @@ -313,7 +313,7 @@ // Write path to frontend_server, since things need to be re-generated when that changes. final String frontendPath = artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk); - await fs.directory(outputPath).childFile('frontend_server.d').writeAsString('frontend_server.d: $frontendPath\n'); + fs.directory(outputPath).childFile('frontend_server.d').writeAsStringSync('frontend_server.d: $frontendPath\n'); return compilerOutput?.outputFilename; }
diff --git a/packages/flutter_tools/lib/src/base/fingerprint.dart b/packages/flutter_tools/lib/src/base/fingerprint.dart index 69ce8fc..663a254 100644 --- a/packages/flutter_tools/lib/src/base/fingerprint.dart +++ b/packages/flutter_tools/lib/src/base/fingerprint.dart
@@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:async'; - import 'package:crypto/crypto.dart' show md5; import 'package:meta/meta.dart'; import 'package:quiver/core.dart' show hash2; @@ -52,12 +50,12 @@ final List<String> _depfilePaths; final FingerprintPathFilter _pathFilter; - Future<Fingerprint> buildFingerprint() async { - final List<String> paths = await _getPaths(); + Fingerprint buildFingerprint() { + final List<String> paths = _getPaths(); return Fingerprint.fromBuildInputs(_properties, paths); } - Future<bool> doesFingerprintMatch() async { + bool doesFingerprintMatch() { if (_disableBuildCache) { return false; } @@ -69,12 +67,12 @@ if (!_depfilePaths.every(fs.isFileSync)) return false; - final List<String> paths = await _getPaths(); + final List<String> paths = _getPaths(); if (!paths.every(fs.isFileSync)) return false; - final Fingerprint oldFingerprint = Fingerprint.fromJson(await fingerprintFile.readAsString()); - final Fingerprint newFingerprint = await buildFingerprint(); + final Fingerprint oldFingerprint = Fingerprint.fromJson(fingerprintFile.readAsStringSync()); + final Fingerprint newFingerprint = buildFingerprint(); return oldFingerprint == newFingerprint; } catch (e) { // Log exception and continue, fingerprinting is only a performance improvement. @@ -83,9 +81,9 @@ return false; } - Future<void> writeFingerprint() async { + void writeFingerprint() { try { - final Fingerprint fingerprint = await buildFingerprint(); + final Fingerprint fingerprint = buildFingerprint(); fs.file(fingerprintPath).writeAsStringSync(fingerprint.toJson()); } catch (e) { // Log exception and continue, fingerprinting is only a performance improvement. @@ -93,11 +91,11 @@ } } - Future<List<String>> _getPaths() async { + List<String> _getPaths() { final Set<String> paths = <String>{ ..._paths, for (String depfilePath in _depfilePaths) - ...await readDepfile(depfilePath), + ...readDepfile(depfilePath), }; final FingerprintPathFilter filter = _pathFilter ?? (String path) => true; return paths.where(filter).toList()..sort(); @@ -183,10 +181,10 @@ /// outfile : file1.dart fil\\e2.dart fil\ e3.dart /// /// will return a set containing: 'file1.dart', 'fil\e2.dart', 'fil e3.dart'. -Future<Set<String>> readDepfile(String depfilePath) async { +Set<String> readDepfile(String depfilePath) { // Depfile format: // outfile1 outfile2 : file1.dart file2.dart file3.dart - final String contents = await fs.file(depfilePath).readAsString(); + final String contents = fs.file(depfilePath).readAsStringSync(); final String dependencies = contents.split(': ')[1]; return dependencies
diff --git a/packages/flutter_tools/lib/src/base/platform.dart b/packages/flutter_tools/lib/src/base/platform.dart index 9ab824d..24d8a55 100644 --- a/packages/flutter_tools/lib/src/base/platform.dart +++ b/packages/flutter_tools/lib/src/base/platform.dart
@@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -import 'dart:async'; - import 'package:platform/platform.dart'; import 'context.dart'; @@ -25,17 +23,17 @@ /// subdirectory. /// /// Returns the existing platform. -Future<Platform> getRecordingPlatform(String location) async { +Platform getRecordingPlatform(String location) { final Directory dir = getRecordingSink(location, _kRecordingType); final File file = _getPlatformManifest(dir); - await file.writeAsString(platform.toJson(), flush: true); + file.writeAsStringSync(platform.toJson(), flush: true); return platform; } -Future<FakePlatform> getReplayPlatform(String location) async { +FakePlatform getReplayPlatform(String location) { final Directory dir = getReplaySource(location, _kRecordingType); final File file = _getPlatformManifest(dir); - final String json = await file.readAsString(); + final String json = file.readAsStringSync(); return FakePlatform.fromJson(json); }
diff --git a/packages/flutter_tools/lib/src/base/process.dart b/packages/flutter_tools/lib/src/base/process.dart index 1dd5765..f94384e 100644 --- a/packages/flutter_tools/lib/src/base/process.dart +++ b/packages/flutter_tools/lib/src/base/process.dart
@@ -15,7 +15,7 @@ typedef StringConverter = String Function(String string); /// A function that will be run before the VM exits. -typedef ShutdownHook = Future<dynamic> Function(); +typedef ShutdownHook = FutureOr<dynamic> Function(); // TODO(ianh): We have way too many ways to run subprocesses in this project. // Convert most of these into one or more lightweight wrappers around the @@ -83,8 +83,12 @@ printTrace('Shutdown hook priority ${stage.priority}'); final List<ShutdownHook> hooks = _shutdownHooks.remove(stage); final List<Future<dynamic>> futures = <Future<dynamic>>[]; - for (ShutdownHook shutdownHook in hooks) - futures.add(shutdownHook()); + for (ShutdownHook shutdownHook in hooks) { + final FutureOr<dynamic> result = shutdownHook(); + if (result is Future<dynamic>) { + futures.add(result); + } + } await Future.wait<dynamic>(futures); } } finally {
diff --git a/packages/flutter_tools/lib/src/build_runner/build_runner.dart b/packages/flutter_tools/lib/src/build_runner/build_runner.dart index 6265c02..a550c8f 100644 --- a/packages/flutter_tools/lib/src/build_runner/build_runner.dart +++ b/packages/flutter_tools/lib/src/build_runner/build_runner.dart
@@ -102,7 +102,7 @@ } stringBuffer.writeln(' build_runner: ^$kMinimumBuildRunnerVersion'); stringBuffer.writeln(' build_daemon: $kSupportedBuildDaemonVersion'); - await syntheticPubspec.writeAsString(stringBuffer.toString()); + syntheticPubspec.writeAsStringSync(stringBuffer.toString()); await pubGet( context: PubContext.pubGet,
diff --git a/packages/flutter_tools/lib/src/build_runner/build_script.dart b/packages/flutter_tools/lib/src/build_runner/build_script.dart index 4a1a284..728a1f3 100644 --- a/packages/flutter_tools/lib/src/build_runner/build_script.dart +++ b/packages/flutter_tools/lib/src/build_runner/build_script.dart
@@ -376,7 +376,7 @@ final Iterable<AssetId> allSrcs = allDeps.expand((Module module) => module.sources); await scratchSpace.ensureAssets(allSrcs, buildStep); - final String packageFile = await _createPackageFile(allSrcs, buildStep, scratchSpace); + final String packageFile = _createPackageFile(allSrcs, buildStep, scratchSpace); final String dartPath = dartEntrypointId.path.startsWith('lib/') ? 'package:${dartEntrypointId.package}/' '${dartEntrypointId.path.substring('lib/'.length)}' @@ -430,7 +430,7 @@ /// The filename is based off the MD5 hash of the asset path so that files are /// unique regarless of situations like `web/foo/bar.dart` vs /// `web/foo-bar.dart`. -Future<String> _createPackageFile(Iterable<AssetId> inputSources, BuildStep buildStep, ScratchSpace scratchSpace) async { +String _createPackageFile(Iterable<AssetId> inputSources, BuildStep buildStep, ScratchSpace scratchSpace) { final Uri inputUri = buildStep.inputId.uri; final String packageFileName = '.package-${md5.convert(inputUri.toString().codeUnits)}'; @@ -439,8 +439,7 @@ final Set<String> packageNames = inputSources.map((AssetId s) => s.package).toSet(); final String packagesFileContent = packageNames.map((String name) => '$name:packages/$name/').join('\n'); - await packagesFile - .writeAsString('# Generated for $inputUri\n$packagesFileContent'); + packagesFile .writeAsStringSync('# Generated for $inputUri\n$packagesFileContent'); return packageFileName; }
diff --git a/packages/flutter_tools/lib/src/build_runner/build_script_generator.dart b/packages/flutter_tools/lib/src/build_runner/build_script_generator.dart index ff010dd..8b59f9b 100644 --- a/packages/flutter_tools/lib/src/build_runner/build_script_generator.dart +++ b/packages/flutter_tools/lib/src/build_runner/build_script_generator.dart
@@ -49,8 +49,8 @@ // ignore_for_file: directives_ordering ${library.accept(emitter)}'''); final File output = fs.file(location); - await output.create(recursive: true); - await fs.file(location).writeAsString(result); + output.createSync(recursive: true); + fs.file(location).writeAsStringSync(result); } on FormatterException { throwToolExit('Generated build script could not be parsed. ' 'This is likely caused by a misconfigured builder definition.');
diff --git a/packages/flutter_tools/lib/src/bundle.dart b/packages/flutter_tools/lib/src/bundle.dart index f298114..573f985 100644 --- a/packages/flutter_tools/lib/src/bundle.dart +++ b/packages/flutter_tools/lib/src/bundle.dart
@@ -99,8 +99,8 @@ } kernelContent = DevFSFileContent(fs.file(compilerOutput.outputFilename)); - await fs.directory(getBuildDirectory()).childFile('frontend_server.d') - .writeAsString('frontend_server.d: ${artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk)}\n'); + fs.directory(getBuildDirectory()).childFile('frontend_server.d') + .writeAsStringSync('frontend_server.d: ${artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk)}\n'); } final AssetBundle assets = await buildAssets(
diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index fa8a198..c29458a 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart
@@ -407,7 +407,7 @@ break; } if (sampleCode != null) { - generatedFileCount += await _applySample(relativeDir, sampleCode); + generatedFileCount += _applySample(relativeDir, sampleCode); } printStatus('Wrote $generatedFileCount files.'); printStatus('\nAll done!'); @@ -566,13 +566,13 @@ // documentation website in sampleCode. Returns the difference in the number // of files after applying the sample, since it also deletes the application's // test directory (since the template's test doesn't apply to the sample). - Future<int> _applySample(Directory directory, String sampleCode) async { + int _applySample(Directory directory, String sampleCode) { final File mainDartFile = directory.childDirectory('lib').childFile('main.dart'); - await mainDartFile.create(recursive: true); - await mainDartFile.writeAsString(sampleCode); + mainDartFile.createSync(recursive: true); + mainDartFile.writeAsStringSync(sampleCode); final Directory testDir = directory.childDirectory('test'); final List<FileSystemEntity> files = testDir.listSync(recursive: true); - await testDir.delete(recursive: true); + testDir.deleteSync(recursive: true); return -files.length; }
diff --git a/packages/flutter_tools/lib/src/commands/packages.dart b/packages/flutter_tools/lib/src/commands/packages.dart index 6078a17..510e9bf 100644 --- a/packages/flutter_tools/lib/src/commands/packages.dart +++ b/packages/flutter_tools/lib/src/commands/packages.dart
@@ -79,9 +79,9 @@ return usageValues; } final FlutterProject rootProject = FlutterProject.fromPath(target); - final bool hasPlugins = await rootProject.flutterPluginsFile.exists(); + final bool hasPlugins = rootProject.flutterPluginsFile.existsSync(); if (hasPlugins) { - final int numberOfPlugins = (await rootProject.flutterPluginsFile.readAsLines()).length; + final int numberOfPlugins = (rootProject.flutterPluginsFile.readAsLinesSync()).length; usageValues[CustomDimensions.commandPackagesNumberPlugins] = '$numberOfPlugins'; } else { usageValues[CustomDimensions.commandPackagesNumberPlugins] = '0';
diff --git a/packages/flutter_tools/lib/src/commands/screenshot.dart b/packages/flutter_tools/lib/src/commands/screenshot.dart index e98f6ed..bda6f33 100644 --- a/packages/flutter_tools/lib/src/commands/screenshot.dart +++ b/packages/flutter_tools/lib/src/commands/screenshot.dart
@@ -106,7 +106,7 @@ } catch (error) { throwToolExit('Error taking screenshot: $error'); } - await showOutputFileInfo(outputFile); + _showOutputFileInfo(outputFile); } Future<void> runSkia(File outputFile) async { @@ -115,8 +115,8 @@ final IOSink sink = outputFile.openWrite(); sink.add(base64.decode(skp['skp'])); await sink.close(); - await showOutputFileInfo(outputFile); - await _ensureOutputIsNotJsonRpcError(outputFile); + _showOutputFileInfo(outputFile); + _ensureOutputIsNotJsonRpcError(outputFile); } Future<void> runRasterizer(File outputFile) async { @@ -125,8 +125,8 @@ final IOSink sink = outputFile.openWrite(); sink.add(base64.decode(response['screenshot'])); await sink.close(); - await showOutputFileInfo(outputFile); - await _ensureOutputIsNotJsonRpcError(outputFile); + _showOutputFileInfo(outputFile); + _ensureOutputIsNotJsonRpcError(outputFile); } Future<Map<String, dynamic>> _invokeVmServiceRpc(String method) async { @@ -135,18 +135,20 @@ return await vmService.vm.invokeRpcRaw(method); } - Future<void> _ensureOutputIsNotJsonRpcError(File outputFile) async { - if (await outputFile.length() < 1000) { - final String content = await outputFile.readAsString( - encoding: const AsciiCodec(allowInvalid: true), - ); - if (content.startsWith('{"jsonrpc":"2.0", "error"')) - throwToolExit('\nIt appears the output file contains an error message, not valid skia output.'); + void _ensureOutputIsNotJsonRpcError(File outputFile) { + if (outputFile.lengthSync() >= 1000) { + return; + } + final String content = outputFile.readAsStringSync( + encoding: const AsciiCodec(allowInvalid: true), + ); + if (content.startsWith('{"jsonrpc":"2.0", "error"')) { + throwToolExit('It appears the output file contains an error message, not valid skia output.'); } } - Future<void> showOutputFileInfo(File outputFile) async { - final int sizeKB = (await outputFile.length()) ~/ 1024; + void _showOutputFileInfo(File outputFile) { + final int sizeKB = (outputFile.lengthSync()) ~/ 1024; printStatus('Screenshot written to ${fs.path.relative(outputFile.path)} (${sizeKB}kB).'); } }
diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index f800f4c..ef8df16 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart
@@ -269,7 +269,7 @@ bool codesign = true, bool usesTerminalUi = true, }) async { - if (!await upgradePbxProjWithFlutterAssets(app.project)) + if (!upgradePbxProjWithFlutterAssets(app.project)) return XcodeBuildResult(success: false); if (!_checkXcodeVersion()) @@ -679,10 +679,10 @@ manifest.writeAsStringSync(json.encode(jsonObject), mode: FileMode.write, flush: true); } -Future<bool> upgradePbxProjWithFlutterAssets(IosProject project) async { +bool upgradePbxProjWithFlutterAssets(IosProject project) { final File xcodeProjectFile = project.xcodeProjectInfoFile; - assert(await xcodeProjectFile.exists()); - final List<String> lines = await xcodeProjectFile.readAsLines(); + assert(xcodeProjectFile.existsSync()); + final List<String> lines = xcodeProjectFile.readAsLinesSync(); final RegExp oldAssets = RegExp(r'\/\* (flutter_assets|app\.flx)'); final StringBuffer buffer = StringBuffer(); @@ -697,6 +697,6 @@ buffer.writeln(line); } } - await xcodeProjectFile.writeAsString(buffer.toString()); + xcodeProjectFile.writeAsStringSync(buffer.toString()); return true; }
diff --git a/packages/flutter_tools/lib/src/macos/cocoapod_utils.dart b/packages/flutter_tools/lib/src/macos/cocoapod_utils.dart index aa7f701..45e3fe9 100644 --- a/packages/flutter_tools/lib/src/macos/cocoapod_utils.dart +++ b/packages/flutter_tools/lib/src/macos/cocoapod_utils.dart
@@ -38,9 +38,9 @@ xcodeProject: xcodeProject, engineDir: flutterFrameworkDir(buildMode), isSwift: xcodeProject.isSwift, - dependenciesChanged: !await fingerprinter.doesFingerprintMatch(), + dependenciesChanged: !fingerprinter.doesFingerprintMatch(), ); if (didPodInstall) { - await fingerprinter.writeFingerprint(); + fingerprinter.writeFingerprint(); } }
diff --git a/packages/flutter_tools/lib/src/macos/cocoapods.dart b/packages/flutter_tools/lib/src/macos/cocoapods.dart index 9729387..ca2577f 100644 --- a/packages/flutter_tools/lib/src/macos/cocoapods.dart +++ b/packages/flutter_tools/lib/src/macos/cocoapods.dart
@@ -106,7 +106,7 @@ bool isSwift = false, bool dependenciesChanged = true, }) async { - if (!(await xcodeProject.podfile.exists())) { + if (!xcodeProject.podfile.existsSync()) { throwToolExit('Podfile missing'); } if (await _checkPodCondition()) {
diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index ac96adb..d5d8bbd 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart
@@ -747,7 +747,7 @@ } } } - final int sizeKB = (await outputFile.length()) ~/ 1024; + final int sizeKB = outputFile.lengthSync() ~/ 1024; status.stop(); printStatus('Screenshot written to ${fs.path.relative(outputFile.path)} (${sizeKB}kB).'); } catch (error) {
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart index de8e4f9..5a16863 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
@@ -303,15 +303,15 @@ ..writeln() ..writeln('# rest') ..writeln(topLevelResults.rest); - await manifest.writeAsString(buffer.toString(), flush: true); + manifest.writeAsStringSync(buffer.toString(), flush: true); // ZIP the recording up once the recording has been serialized. - addShutdownHook(() async { + addShutdownHook(() { final File zipFile = getUniqueFile(fs.currentDirectory, 'bugreport', 'zip'); os.zip(tempDir, zipFile); printStatus(userMessages.runnerBugReportFinished(zipFile.basename)); }, ShutdownStage.POST_PROCESS_RECORDING); - addShutdownHook(() => tempDir.delete(recursive: true), ShutdownStage.CLEANUP); + addShutdownHook(() => tempDir.deleteSync(recursive: true), ShutdownStage.CLEANUP); } assert(recordTo == null || replayFrom == null); @@ -323,7 +323,7 @@ contextOverrides.addAll(<Type, dynamic>{ ProcessManager: getRecordingProcessManager(recordTo), FileSystem: getRecordingFileSystem(recordTo), - Platform: await getRecordingPlatform(recordTo), + Platform: getRecordingPlatform(recordTo), }); VMService.enableRecordingConnection(recordTo); } @@ -335,7 +335,7 @@ contextOverrides.addAll(<Type, dynamic>{ ProcessManager: await getReplayProcessManager(replayFrom), FileSystem: getReplayFileSystem(replayFrom), - Platform: await getReplayPlatform(replayFrom), + Platform: getReplayPlatform(replayFrom), }); VMService.enableReplayConnection(replayFrom); }
diff --git a/packages/flutter_tools/lib/src/tracing.dart b/packages/flutter_tools/lib/src/tracing.dart index 0a2de0c..f208305 100644 --- a/packages/flutter_tools/lib/src/tracing.dart +++ b/packages/flutter_tools/lib/src/tracing.dart
@@ -78,12 +78,14 @@ final File traceInfoFile = fs.file(traceInfoFilePath); // Delete old startup data, if any. - if (await traceInfoFile.exists()) - await traceInfoFile.delete(); + if (traceInfoFile.existsSync()) { + traceInfoFile.deleteSync(); + } // Create "build" directory, if missing. - if (!(await traceInfoFile.parent.exists())) - await traceInfoFile.parent.create(); + if (!traceInfoFile.parent.existsSync()) { + traceInfoFile.parent.createSync(); + } final Tracing tracing = Tracing(observatory);
diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart index f1f4a42..61666df 100644 --- a/packages/flutter_tools/lib/src/version.dart +++ b/packages/flutter_tools/lib/src/version.dart
@@ -99,8 +99,9 @@ String get engineRevision => Cache.instance.engineRevision; String get engineRevisionShort => _shortGitRevision(engineRevision); - Future<void> ensureVersionFile() async { + Future<void> ensureVersionFile() { fs.file(fs.path.join(Cache.flutterRoot, 'version')).writeAsStringSync(_frameworkVersion); + return Future<void>.value(); } @override
diff --git a/packages/flutter_tools/lib/src/vmservice_record_replay.dart b/packages/flutter_tools/lib/src/vmservice_record_replay.dart index 9da5bf4..dcf04a2 100644 --- a/packages/flutter_tools/lib/src/vmservice_record_replay.dart +++ b/packages/flutter_tools/lib/src/vmservice_record_replay.dart
@@ -24,7 +24,7 @@ class RecordingVMServiceChannel extends DelegatingStreamChannel<String> { RecordingVMServiceChannel(StreamChannel<String> delegate, Directory location) : super(delegate) { - addShutdownHook(() async { + addShutdownHook(() { // Sort the messages such that they are ordered // `[request1, response1, request2, response2, ...]`. This serves no // purpose other than to make the serialized format more human-readable. @@ -32,7 +32,7 @@ final File file = _getManifest(location); final String json = const JsonEncoder.withIndent(' ').convert(_messages); - await file.writeAsString(json, flush: true); + file.writeAsStringSync(json, flush: true); }, ShutdownStage.SERIALIZE_RECORDING); }