Migrate build_macos and web_test_compiler to null safety (#84469)

diff --git a/packages/flutter_tools/lib/src/macos/build_macos.dart b/packages/flutter_tools/lib/src/macos/build_macos.dart
index 2f36a35..e304bad 100644
--- a/packages/flutter_tools/lib/src/macos/build_macos.dart
+++ b/packages/flutter_tools/lib/src/macos/build_macos.dart
@@ -2,10 +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:meta/meta.dart';
-
 import '../base/analyze_size.dart';
 import '../base/common.dart';
 import '../base/file_system.dart';
@@ -27,11 +23,11 @@
 /// Builds the macOS project through xcodebuild.
 // TODO(jonahwilliams): refactor to share code with the existing iOS code.
 Future<void> buildMacOS({
-  FlutterProject flutterProject,
-  BuildInfo buildInfo,
-  String targetOverride,
-  @required bool verboseLogging,
-  SizeAnalyzer sizeAnalyzer,
+  required FlutterProject flutterProject,
+  required BuildInfo buildInfo,
+  String? targetOverride,
+  required bool verboseLogging,
+  SizeAnalyzer? sizeAnalyzer,
 }) async {
   if (!flutterProject.macos.xcodeWorkspace.existsSync()) {
     throwToolExit('No macOS desktop project configured. '
@@ -77,16 +73,16 @@
   // If the standard project exists, specify it to getInfo to handle the case where there are
   // other Xcode projects in the macos/ directory. Otherwise pass no name, which will work
   // regardless of the project name so long as there is exactly one project.
-  final String xcodeProjectName = xcodeProject.existsSync() ? xcodeProject.basename : null;
-  final XcodeProjectInfo projectInfo = await globals.xcodeProjectInterpreter.getInfo(
+  final String? xcodeProjectName = xcodeProject.existsSync() ? xcodeProject.basename : null;
+  final XcodeProjectInfo projectInfo = await globals.xcodeProjectInterpreter!.getInfo(
     xcodeProject.parent.path,
     projectFilename: xcodeProjectName,
   );
-  final String scheme = projectInfo.schemeFor(buildInfo);
+  final String? scheme = projectInfo.schemeFor(buildInfo);
   if (scheme == null) {
     projectInfo.reportFlavorNotFoundAndExit();
   }
-  final String configuration = projectInfo.buildConfigurationFor(buildInfo, scheme);
+  final String? configuration = projectInfo.buildConfigurationFor(buildInfo, scheme);
   if (configuration == null) {
     throwToolExit('Unable to find expected configuration in Xcode project.');
   }
@@ -141,7 +137,7 @@
       .firstWhere((Directory directory) {
       return globals.fs.path.extension(directory.path) == '.app';
     });
-    final Map<String, Object> output = await sizeAnalyzer.analyzeAotSnapshot(
+    final Map<String, Object?> output = await sizeAnalyzer.analyzeAotSnapshot(
       aotSnapshot: aotSnapshot,
       precompilerTrace: precompilerTrace,
       outputDirectory: appDirectory,
diff --git a/packages/flutter_tools/lib/src/test/web_test_compiler.dart b/packages/flutter_tools/lib/src/test/web_test_compiler.dart
index 8e8bd8f..cf05c3f 100644
--- a/packages/flutter_tools/lib/src/test/web_test_compiler.dart
+++ b/packages/flutter_tools/lib/src/test/web_test_compiler.dart
@@ -2,9 +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:meta/meta.dart';
 import 'package:package_config/package_config.dart';
 import 'package:process/process.dart';
 
@@ -26,12 +23,12 @@
 /// A web compiler for the test runner.
 class WebTestCompiler {
   WebTestCompiler({
-    @required FileSystem fileSystem,
-    @required Logger logger,
-    @required Artifacts artifacts,
-    @required Platform platform,
-    @required ProcessManager processManager,
-    @required Config config,
+    required FileSystem fileSystem,
+    required Logger logger,
+    required Artifacts artifacts,
+    required Platform platform,
+    required ProcessManager processManager,
+    required Config config,
   }) : _logger = logger,
        _fileSystem = fileSystem,
        _artifacts = artifacts,
@@ -47,24 +44,23 @@
   final Config _config;
 
   Future<WebMemoryFS> initialize({
-    @required Directory projectDirectory,
-    @required String testOutputDir,
-    @required List<String> testFiles,
-    @required BuildInfo buildInfo,
+    required Directory projectDirectory,
+    required String testOutputDir,
+    required List<String> testFiles,
+    required BuildInfo buildInfo,
   }) async {
     LanguageVersion languageVersion = LanguageVersion(2, 8);
-    HostArtifact platformDillArtifact;
+    HostArtifact platformDillArtifact = HostArtifact.webPlatformSoundKernelDill;
     // TODO(jonahwilliams): to support autodetect this would need to partition the source code into a
     // a sound and unsound set and perform separate compilations.
-    final List<String> extraFrontEndOptions = List<String>.of(buildInfo.extraFrontEndOptions ?? <String>[]);
+    final List<String> extraFrontEndOptions = List<String>.of(buildInfo.extraFrontEndOptions);
     if (buildInfo.nullSafetyMode == NullSafetyMode.unsound || buildInfo.nullSafetyMode == NullSafetyMode.autodetect) {
       platformDillArtifact = HostArtifact.webPlatformKernelDill;
       if (!extraFrontEndOptions.contains('--no-sound-null-safety')) {
         extraFrontEndOptions.add('--no-sound-null-safety');
       }
     } else if (buildInfo.nullSafetyMode == NullSafetyMode.sound) {
-      platformDillArtifact = HostArtifact.webPlatformSoundKernelDill;
-      languageVersion = currentLanguageVersion(_fileSystem, Cache.flutterRoot);
+      languageVersion = currentLanguageVersion(_fileSystem, Cache.flutterRoot!);
       if (!extraFrontEndOptions.contains('--sound-null-safety')) {
         extraFrontEndOptions.add('--sound-null-safety');
       }
@@ -133,7 +129,7 @@
       fileSystem: _fileSystem,
     );
 
-    final CompilerOutput output = await residentCompiler.recompile(
+    final CompilerOutput? output = await residentCompiler.recompile(
       Uri.parse('org-dartlang-app:///main.dart'),
       <Uri>[],
       outputPath: outputDirectory.childFile('out').path,
@@ -141,7 +137,7 @@
       fs: _fileSystem,
       projectRootPath: projectDirectory.absolute.path,
     );
-    if (output.errorCount > 0) {
+    if (output == null || output.errorCount > 0) {
       throwToolExit('Failed to compile');
     }
     // Cache the output kernel file to speed up subsequent compiles.