Unverified Commit 94894586 authored by Liam Appelbe's avatar Liam Appelbe Committed by GitHub

Reland "Null safety migration of packages/flutter_tools/bin" (#111756)

This reverts commit f8f69575.
parent da4e4054
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_tools/executable.dart' as executable;
void main(List<String> args) {
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:args/args.dart';
import 'package:flutter_tools/src/asset.dart' hide defaultManifestPath;
import 'package:flutter_tools/src/base/common.dart';
......@@ -63,10 +61,10 @@ Future<void> run(List<String> args) async {
Cache.flutterRoot = globals.platform.environment['FLUTTER_ROOT'];
final String assetDir = argResults[_kOptionAsset] as String;
final AssetBundle assets = await buildAssets(
manifestPath: argResults[_kOptionManifest] as String ?? defaultManifestPath,
final AssetBundle? assets = await buildAssets(
manifestPath: argResults[_kOptionManifest] as String? ?? defaultManifestPath,
assetDirPath: assetDir,
packagesPath: argResults[_kOptionPackages] as String,
packagesPath: argResults[_kOptionPackages] as String?,
targetPlatform: TargetPlatform.fuchsia_arm64 // This is not arch specific.
);
......@@ -84,8 +82,9 @@ Future<void> run(List<String> args) async {
final String outputMan = argResults[_kOptionAssetManifestOut] as String;
await writeFuchsiaManifest(assets, argResults[_kOptionAsset] as String, outputMan, argResults[_kOptionComponentName] as String);
if (argResults.options.contains(_kOptionDepfile)) {
await writeDepfile(assets, outputMan, argResults[_kOptionDepfile] as String);
final String? depfilePath = argResults[_kOptionDepfile] as String?;
if (depfilePath != null) {
await writeDepfile(assets, outputMan, depfilePath);
}
}
......
......@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:convert' show json;
import 'dart:math' as math;
......@@ -57,7 +55,6 @@ Future<void> run(List<String> args) async {
..addOption(_kOptionTests, help: 'Path to json file that maps Dart test files to precompiled dill files')
..addOption(_kOptionCoverageDirectory, help: 'The path to the directory that will have coverage collected')
..addFlag(_kOptionCoverage,
defaultsTo: false,
negatable: false,
help: 'Whether to collect coverage information.',
)
......@@ -84,7 +81,7 @@ Future<void> run(List<String> args) async {
if (!globals.fs.isDirectorySync(sdkRootSrc.path)) {
throwToolExit('Cannot find SDK files at ${sdkRootSrc.path}');
}
Directory coverageDirectory;
Directory? coverageDirectory;
final String coverageDirectoryPath = argResults[_kOptionCoverageDirectory] as String;
if (coverageDirectoryPath != null) {
if (!globals.fs.isDirectorySync(coverageDirectoryPath)) {
......@@ -95,13 +92,14 @@ Future<void> run(List<String> args) async {
// Put the tester shell where runTests expects it.
// TODO(garymm): Switch to a Fuchsia-specific Artifacts impl.
final Artifacts artifacts = globals.artifacts!;
final Link testerDestLink =
globals.fs.link(globals.artifacts.getArtifactPath(Artifact.flutterTester));
globals.fs.link(artifacts.getArtifactPath(Artifact.flutterTester));
testerDestLink.parent.createSync(recursive: true);
testerDestLink.createSync(globals.fs.path.absolute(shellPath));
final Directory sdkRootDest =
globals.fs.directory(globals.artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath));
globals.fs.directory(artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath));
sdkRootDest.createSync(recursive: true);
for (final FileSystemEntity artifact in sdkRootSrc.listSync()) {
globals.fs.link(sdkRootDest.childFile(artifact.basename).path).createSync(artifact.path);
......@@ -109,12 +107,12 @@ Future<void> run(List<String> args) async {
// TODO(tvolkert): Remove once flutter_tester no longer looks for this.
globals.fs.link(sdkRootDest.childFile('platform.dill').path).createSync('platform_strong.dill');
Directory testDirectory;
CoverageCollector collector;
Directory? testDirectory;
CoverageCollector? collector;
if (argResults['coverage'] as bool) {
// If we have a specified coverage directory then accept all libraries by
// setting libraryNames to null.
final Set<String> libraryNames = coverageDirectory != null ? null :
final Set<String>? libraryNames = coverageDirectory != null ? null :
<String>{FlutterProject.current().manifest.appName};
final String packagesPath = globals.fs.path.normalize(globals.fs.path.absolute(argResults[_kOptionPackages] as String));
collector = CoverageCollector(
......@@ -162,7 +160,7 @@ Future<void> run(List<String> args) async {
// package (i.e. contains lib/ and test/ sub-dirs). In some cases,
// test files may appear to be in the root directory.
if (coverageDirectory == null) {
globals.fs.currentDirectory = testDirectory.parent;
globals.fs.currentDirectory = testDirectory!.parent;
} else {
globals.fs.currentDirectory = testDirectory;
}
......
......@@ -521,9 +521,9 @@ class ResidentWebRunner extends ResidentRunner {
}) async {
if (_chromiumLauncher != null) {
final Chromium chrome = await _chromiumLauncher!.connectedInstance;
final ChromeTab chromeTab = await (chrome.chromeConnection.getTab((ChromeTab chromeTab) {
final ChromeTab? chromeTab = await chrome.chromeConnection.getTab((ChromeTab chromeTab) {
return !chromeTab.url.startsWith('chrome-extension');
}, retryFor: const Duration(seconds: 5)) as FutureOr<ChromeTab>);
}, retryFor: const Duration(seconds: 5));
if (chromeTab == null) {
throwToolExit('Failed to connect to Chrome instance.');
}
......
......@@ -261,14 +261,14 @@ class Placeholder {
if (value == null) {
return <OptionalParameter>[];
}
if (value is! Map<String, Object>) {
if (value is! Map<String, Object?>) {
throw L10nException(
'The "optionalParameters" value of the "$name" placeholder in message '
'$resourceId is not a properly formatted Map. Ensure that it is a map '
'with keys that are strings.'
);
}
final Map<String, Object> optionalParameterMap = value;
final Map<String, Object?> optionalParameterMap = value;
return optionalParameterMap.keys.map<OptionalParameter>((String parameterName) {
return OptionalParameter(parameterName, optionalParameterMap[parameterName]!);
}).toList();
......
......@@ -348,7 +348,7 @@ StreamChannel<String> _webSocketToStreamChannel(WebSocket webSocket) {
.pipe(webSocket);
webSocket
// We're only communicating with string encoded JSON.
.map<String?>((dynamic message) => message as String?)
.map<String>((dynamic message) => message as String)
.pipe(controller.local.sink);
return controller.foreign;
......
......@@ -344,7 +344,7 @@ class FlutterWebPlatform extends PlatformPlugin {
Future<shelf.Response> _goldenFileHandler(shelf.Request request) async {
if (request.url.path.contains('flutter_goldens')) {
final Map<String, Object> body = json.decode(await request.readAsString()) as Map<String, Object>;
final Map<String, Object?> body = json.decode(await request.readAsString()) as Map<String, Object?>;
final Uri goldenKey = Uri.parse(body['key']! as String);
final Uri testUri = Uri.parse(body['testUri']! as String);
final num width = body['width']! as num;
......@@ -352,9 +352,9 @@ class FlutterWebPlatform extends PlatformPlugin {
Uint8List bytes;
try {
final ChromeTab chromeTab = await (_browserManager!._browser.chromeConnection.getTab((ChromeTab tab) {
final ChromeTab chromeTab = (await _browserManager!._browser.chromeConnection.getTab((ChromeTab tab) {
return tab.url.contains(_browserManager!._browser.url!);
}) as FutureOr<ChromeTab>);
}))!;
final WipConnection connection = await chromeTab.connect();
final WipResponse response = await connection.sendCommand('Page.captureScreenshot', <String, Object>{
// Clip the screenshot to include only the element.
......
......@@ -158,7 +158,7 @@ abstract class ChromiumDevice extends Device {
@override
Future<bool> stopApp(
ApplicationPackage app, {
ApplicationPackage? app, {
String? userIdentifier,
}) async {
await _chrome?.close();
......@@ -479,7 +479,7 @@ class WebServerDevice extends Device {
@override
Future<bool> stopApp(
ApplicationPackage app, {
ApplicationPackage? app, {
String? userIdentifier,
}) async {
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment