Skip to content

Commit f8f6957

Browse files
authored
Revert "Null safety migration of packages/flutter_tools/bin" (#111506)
1 parent 126db3b commit f8f6957

File tree

8 files changed

+29
-24
lines changed

8 files changed

+29
-24
lines changed

packages/flutter_tools/bin/flutter_tools.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
// @dart = 2.8
6+
57
import 'package:flutter_tools/executable.dart' as executable;
68

79
void main(List<String> args) {

packages/flutter_tools/bin/fuchsia_asset_builder.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
// @dart = 2.8
6+
57
import 'package:args/args.dart';
68
import 'package:flutter_tools/src/asset.dart' hide defaultManifestPath;
79
import 'package:flutter_tools/src/base/common.dart';
@@ -61,10 +63,10 @@ Future<void> run(List<String> args) async {
6163
Cache.flutterRoot = globals.platform.environment['FLUTTER_ROOT'];
6264

6365
final String assetDir = argResults[_kOptionAsset] as String;
64-
final AssetBundle? assets = await buildAssets(
65-
manifestPath: argResults[_kOptionManifest] as String? ?? defaultManifestPath,
66+
final AssetBundle assets = await buildAssets(
67+
manifestPath: argResults[_kOptionManifest] as String ?? defaultManifestPath,
6668
assetDirPath: assetDir,
67-
packagesPath: argResults[_kOptionPackages] as String?,
69+
packagesPath: argResults[_kOptionPackages] as String,
6870
targetPlatform: TargetPlatform.fuchsia_arm64 // This is not arch specific.
6971
);
7072

@@ -82,9 +84,8 @@ Future<void> run(List<String> args) async {
8284
final String outputMan = argResults[_kOptionAssetManifestOut] as String;
8385
await writeFuchsiaManifest(assets, argResults[_kOptionAsset] as String, outputMan, argResults[_kOptionComponentName] as String);
8486

85-
final String? depfilePath = argResults[_kOptionDepfile] as String?;
86-
if (depfilePath != null) {
87-
await writeDepfile(assets, outputMan, depfilePath);
87+
if (argResults.options.contains(_kOptionDepfile)) {
88+
await writeDepfile(assets, outputMan, argResults[_kOptionDepfile] as String);
8889
}
8990
}
9091

packages/flutter_tools/bin/fuchsia_tester.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
// @dart = 2.8
6+
57
import 'dart:convert' show json;
68
import 'dart:math' as math;
79

@@ -55,6 +57,7 @@ Future<void> run(List<String> args) async {
5557
..addOption(_kOptionTests, help: 'Path to json file that maps Dart test files to precompiled dill files')
5658
..addOption(_kOptionCoverageDirectory, help: 'The path to the directory that will have coverage collected')
5759
..addFlag(_kOptionCoverage,
60+
defaultsTo: false,
5861
negatable: false,
5962
help: 'Whether to collect coverage information.',
6063
)
@@ -81,7 +84,7 @@ Future<void> run(List<String> args) async {
8184
if (!globals.fs.isDirectorySync(sdkRootSrc.path)) {
8285
throwToolExit('Cannot find SDK files at ${sdkRootSrc.path}');
8386
}
84-
Directory? coverageDirectory;
87+
Directory coverageDirectory;
8588
final String coverageDirectoryPath = argResults[_kOptionCoverageDirectory] as String;
8689
if (coverageDirectoryPath != null) {
8790
if (!globals.fs.isDirectorySync(coverageDirectoryPath)) {
@@ -92,27 +95,26 @@ Future<void> run(List<String> args) async {
9295

9396
// Put the tester shell where runTests expects it.
9497
// TODO(garymm): Switch to a Fuchsia-specific Artifacts impl.
95-
final Artifacts artifacts = globals.artifacts!;
9698
final Link testerDestLink =
97-
globals.fs.link(artifacts.getArtifactPath(Artifact.flutterTester));
99+
globals.fs.link(globals.artifacts.getArtifactPath(Artifact.flutterTester));
98100
testerDestLink.parent.createSync(recursive: true);
99101
testerDestLink.createSync(globals.fs.path.absolute(shellPath));
100102

101103
final Directory sdkRootDest =
102-
globals.fs.directory(artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath));
104+
globals.fs.directory(globals.artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath));
103105
sdkRootDest.createSync(recursive: true);
104106
for (final FileSystemEntity artifact in sdkRootSrc.listSync()) {
105107
globals.fs.link(sdkRootDest.childFile(artifact.basename).path).createSync(artifact.path);
106108
}
107109
// TODO(tvolkert): Remove once flutter_tester no longer looks for this.
108110
globals.fs.link(sdkRootDest.childFile('platform.dill').path).createSync('platform_strong.dill');
109111

110-
Directory? testDirectory;
111-
CoverageCollector? collector;
112+
Directory testDirectory;
113+
CoverageCollector collector;
112114
if (argResults['coverage'] as bool) {
113115
// If we have a specified coverage directory then accept all libraries by
114116
// setting libraryNames to null.
115-
final Set<String>? libraryNames = coverageDirectory != null ? null :
117+
final Set<String> libraryNames = coverageDirectory != null ? null :
116118
<String>{FlutterProject.current().manifest.appName};
117119
final String packagesPath = globals.fs.path.normalize(globals.fs.path.absolute(argResults[_kOptionPackages] as String));
118120
collector = CoverageCollector(
@@ -160,7 +162,7 @@ Future<void> run(List<String> args) async {
160162
// package (i.e. contains lib/ and test/ sub-dirs). In some cases,
161163
// test files may appear to be in the root directory.
162164
if (coverageDirectory == null) {
163-
globals.fs.currentDirectory = testDirectory!.parent;
165+
globals.fs.currentDirectory = testDirectory.parent;
164166
} else {
165167
globals.fs.currentDirectory = testDirectory;
166168
}

packages/flutter_tools/lib/src/isolated/resident_web_runner.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,9 @@ class ResidentWebRunner extends ResidentRunner {
521521
}) async {
522522
if (_chromiumLauncher != null) {
523523
final Chromium chrome = await _chromiumLauncher!.connectedInstance;
524-
final ChromeTab? chromeTab = await chrome.chromeConnection.getTab((ChromeTab chromeTab) {
524+
final ChromeTab chromeTab = await (chrome.chromeConnection.getTab((ChromeTab chromeTab) {
525525
return !chromeTab.url.startsWith('chrome-extension');
526-
}, retryFor: const Duration(seconds: 5));
526+
}, retryFor: const Duration(seconds: 5)) as FutureOr<ChromeTab>);
527527
if (chromeTab == null) {
528528
throwToolExit('Failed to connect to Chrome instance.');
529529
}

packages/flutter_tools/lib/src/localizations/gen_l10n_types.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,14 @@ class Placeholder {
261261
if (value == null) {
262262
return <OptionalParameter>[];
263263
}
264-
if (value is! Map<String, Object?>) {
264+
if (value is! Map<String, Object>) {
265265
throw L10nException(
266266
'The "optionalParameters" value of the "$name" placeholder in message '
267267
'$resourceId is not a properly formatted Map. Ensure that it is a map '
268268
'with keys that are strings.'
269269
);
270270
}
271-
final Map<String, Object?> optionalParameterMap = value;
271+
final Map<String, Object> optionalParameterMap = value;
272272
return optionalParameterMap.keys.map<OptionalParameter>((String parameterName) {
273273
return OptionalParameter(parameterName, optionalParameterMap[parameterName]!);
274274
}).toList();

packages/flutter_tools/lib/src/test/flutter_tester_device.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ StreamChannel<String> _webSocketToStreamChannel(WebSocket webSocket) {
348348
.pipe(webSocket);
349349
webSocket
350350
// We're only communicating with string encoded JSON.
351-
.map<String>((dynamic message) => message as String)
351+
.map<String?>((dynamic message) => message as String?)
352352
.pipe(controller.local.sink);
353353

354354
return controller.foreign;

packages/flutter_tools/lib/src/test/flutter_web_platform.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,17 @@ class FlutterWebPlatform extends PlatformPlugin {
344344

345345
Future<shelf.Response> _goldenFileHandler(shelf.Request request) async {
346346
if (request.url.path.contains('flutter_goldens')) {
347-
final Map<String, Object?> body = json.decode(await request.readAsString()) as Map<String, Object?>;
347+
final Map<String, Object> body = json.decode(await request.readAsString()) as Map<String, Object>;
348348
final Uri goldenKey = Uri.parse(body['key']! as String);
349349
final Uri testUri = Uri.parse(body['testUri']! as String);
350350
final num width = body['width']! as num;
351351
final num height = body['height']! as num;
352352
Uint8List bytes;
353353

354354
try {
355-
final ChromeTab chromeTab = (await _browserManager!._browser.chromeConnection.getTab((ChromeTab tab) {
355+
final ChromeTab chromeTab = await (_browserManager!._browser.chromeConnection.getTab((ChromeTab tab) {
356356
return tab.url.contains(_browserManager!._browser.url!);
357-
}))!;
357+
}) as FutureOr<ChromeTab>);
358358
final WipConnection connection = await chromeTab.connect();
359359
final WipResponse response = await connection.sendCommand('Page.captureScreenshot', <String, Object>{
360360
// Clip the screenshot to include only the element.

packages/flutter_tools/lib/src/web/web_device.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ abstract class ChromiumDevice extends Device {
158158

159159
@override
160160
Future<bool> stopApp(
161-
ApplicationPackage? app, {
161+
ApplicationPackage app, {
162162
String? userIdentifier,
163163
}) async {
164164
await _chrome?.close();
@@ -479,7 +479,7 @@ class WebServerDevice extends Device {
479479

480480
@override
481481
Future<bool> stopApp(
482-
ApplicationPackage? app, {
482+
ApplicationPackage app, {
483483
String? userIdentifier,
484484
}) async {
485485
return true;

0 commit comments

Comments
 (0)