Version 2.13.0-202.0.dev

Merge commit '3ea23d2f55ac3453ec2953fe258f3ea8d562c39b' into 'dev'
diff --git a/pkg/analysis_server/lib/src/domain_analysis.dart b/pkg/analysis_server/lib/src/domain_analysis.dart
index a34a056..a9b8464 100644
--- a/pkg/analysis_server/lib/src/domain_analysis.dart
+++ b/pkg/analysis_server/lib/src/domain_analysis.dart
@@ -12,6 +12,7 @@
 import 'package:analysis_server/src/computer/computer_signature.dart';
 import 'package:analysis_server/src/computer/imported_elements_computer.dart';
 import 'package:analysis_server/src/domain_abstract.dart';
+import 'package:analysis_server/src/domain_analysis_flags.dart';
 import 'package:analysis_server/src/plugin/request_converter.dart';
 import 'package:analysis_server/src/plugin/result_merger.dart';
 import 'package:analysis_server/src/protocol/protocol_internal.dart';
@@ -22,9 +23,6 @@
 import 'package:analyzer_plugin/src/utilities/navigation/navigation.dart';
 import 'package:analyzer_plugin/utilities/navigation/navigation_dart.dart';
 
-// TODO(devoncarew): See #31456 for the tracking issue to remove this flag.
-final bool disableManageImportsOnPaste = true;
-
 /// Instances of the class [AnalysisDomainHandler] implement a [RequestHandler]
 /// that handles requests in the `analysis` domain.
 class AnalysisDomainHandler extends AbstractRequestHandler {
diff --git a/pkg/analysis_server/lib/src/domain_analysis_flags.dart b/pkg/analysis_server/lib/src/domain_analysis_flags.dart
new file mode 100644
index 0000000..c1196be
--- /dev/null
+++ b/pkg/analysis_server/lib/src/domain_analysis_flags.dart
@@ -0,0 +1,6 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// TODO(devoncarew): See #31456 for the tracking issue to remove this flag.
+final bool disableManageImportsOnPaste = true;
diff --git a/pkg/analysis_server/test/integration/analysis/analysis_options_test.dart b/pkg/analysis_server/test/integration/analysis/analysis_options_test.dart
index d0afbc3..5033928 100644
--- a/pkg/analysis_server/test/integration/analysis/analysis_options_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/analysis_options_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analyzer/src/util/file_paths.dart' as file_paths;
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
@@ -38,7 +36,7 @@
     await analysisFinished;
 
     expect(currentAnalysisErrors[options], isList);
-    var errors = currentAnalysisErrors[options];
+    var errors = existingErrorsForFile(options);
     expect(errors, hasLength(1));
     var error = errors[0];
     expect(error.location.file, options);
diff --git a/pkg/analysis_server/test/integration/analysis/error_test.dart b/pkg/analysis_server/test/integration/analysis/error_test.dart
index b5d5fb7..e674a76 100644
--- a/pkg/analysis_server/test/integration/analysis/error_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/error_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
@@ -33,7 +31,7 @@
     await analysisFinished;
 
     expect(currentAnalysisErrors[filePath], isList);
-    var errors = currentAnalysisErrors[filePath];
+    var errors = existingErrorsForFile(filePath);
     expect(errors, hasLength(1));
     expect(errors[0].location.file, equals(filePath));
   }
@@ -47,7 +45,7 @@
     standardAnalysisSetup();
     return analysisFinished.then((_) {
       expect(currentAnalysisErrors[pathname], isList);
-      var errors = currentAnalysisErrors[pathname];
+      var errors = existingErrorsForFile(pathname);
       expect(errors, hasLength(1));
       expect(errors[0].location.file, equals(pathname));
     });
diff --git a/pkg/analysis_server/test/integration/analysis/get_errors_non_standard_sdk_test.dart b/pkg/analysis_server/test/integration/analysis/get_errors_non_standard_sdk_test.dart
index 1b0de2d..fb8cb1e 100644
--- a/pkg/analysis_server/test/integration/analysis/get_errors_non_standard_sdk_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/get_errors_non_standard_sdk_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:io';
 
 import 'package:path/path.dart' as path;
@@ -78,7 +76,7 @@
   }
 
   @override
-  Future startServer({int diagnosticPort, int servicesPort}) {
+  Future startServer({int? diagnosticPort, int? servicesPort}) {
     var sdkPath = createNonStandardSdk();
     return server.start(
         diagnosticPort: diagnosticPort,
@@ -95,7 +93,7 @@
     writeFile(pathname, text);
     standardAnalysisSetup();
     await analysisFinished;
-    var errors = currentAnalysisErrors[pathname];
+    var errors = existingErrorsForFile(pathname);
     expect(errors, hasLength(1));
     expect(errors[0].code, 'unused_import');
   }
diff --git a/pkg/analysis_server/test/integration/analysis/get_errors_test.dart b/pkg/analysis_server/test/integration/analysis/get_errors_test.dart
index 61d8b52..260cb6c 100644
--- a/pkg/analysis_server/test/integration/analysis/get_errors_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/get_errors_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/analysis/get_hover_test.dart b/pkg/analysis_server/test/integration/analysis/get_hover_test.dart
index 6da5c92..2c4828c 100644
--- a/pkg/analysis_server/test/integration/analysis/get_hover_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/get_hover_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:path/path.dart' as path;
 import 'package:test/test.dart';
@@ -21,7 +19,7 @@
 class AnalysisGetHoverIntegrationTest
     extends AbstractAnalysisServerIntegrationTest {
   /// Pathname of the file containing Dart code.
-  String pathname;
+  late String pathname;
 
   /// Dart code under test.
   final String text = r'''
@@ -55,17 +53,17 @@
   /// literal value.  [parameterRegexps] means is a set of regexps which should
   /// match the hover parameters.  [propagatedType], if specified, is the
   /// expected propagated type of the element.
-  Future<AnalysisGetHoverResult> checkHover(
+  Future<AnalysisGetHoverResult?> checkHover(
     String target,
     int length,
-    List<String> descriptionRegexps,
-    String kind,
-    List<String> staticTypeRegexps, {
+    List<String>? descriptionRegexps,
+    String? kind,
+    List<String>? staticTypeRegexps, {
     bool isLocal = false,
     bool isCore = false,
-    String docRegexp,
+    String? docRegexp,
     bool isLiteral = false,
-    List<String> parameterRegexps,
+    List<String>? parameterRegexps,
   }) {
     var offset = text.indexOf(target);
     return sendAnalysisGetHover(pathname, offset).then((result) async {
@@ -74,7 +72,7 @@
       expect(info.offset, equals(offset));
       expect(info.length, equals(length));
       if (isCore) {
-        expect(path.basename(info.containingLibraryPath), equals('core.dart'));
+        expect(path.basename(info.containingLibraryPath!), equals('core.dart'));
         expect(info.containingLibraryName, equals('dart:core'));
       } else if (isLocal || isLiteral) {
         expect(info.containingLibraryPath, isNull);
diff --git a/pkg/analysis_server/test/integration/analysis/get_imported_elements_test.dart b/pkg/analysis_server/test/integration/analysis/get_imported_elements_test.dart
index 6aac49a..547b6d9 100644
--- a/pkg/analysis_server/test/integration/analysis/get_imported_elements_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/get_imported_elements_test.dart
@@ -2,10 +2,8 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
-import 'package:analysis_server/src/domain_analysis.dart';
+import 'package:analysis_server/src/domain_analysis_flags.dart';
 import 'package:path/path.dart' as path;
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -22,10 +20,10 @@
 class AnalysisGetImportedElementsIntegrationTest
     extends AbstractAnalysisServerIntegrationTest {
   /// Pathname of the file containing Dart code.
-  String pathname;
+  late String pathname;
 
   /// Dart code under test.
-  String text;
+  late String text;
 
   /// Check that an analysis.getImportedElements request on the region starting
   /// with the first character that matches [target] and having the given
diff --git a/pkg/analysis_server/test/integration/analysis/get_library_dependencies_test.dart b/pkg/analysis_server/test/integration/analysis/get_library_dependencies_test.dart
index ff3fd0f..caf757e 100644
--- a/pkg/analysis_server/test/integration/analysis/get_library_dependencies_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/get_library_dependencies_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -41,7 +39,7 @@
     expect(libraries.any((String lib) => lib.endsWith('core/core.dart')), true);
 
     expect(packageMaps.keys, hasLength(1));
-    var map = packageMaps[packageMaps.keys.first];
+    var map = packageMaps[packageMaps.keys.first]!;
     expect(map.keys, isEmpty);
   }
 }
diff --git a/pkg/analysis_server/test/integration/analysis/get_navigation_test.dart b/pkg/analysis_server/test/integration/analysis/get_navigation_test.dart
index fc0a57b..1288adb 100644
--- a/pkg/analysis_server/test/integration/analysis/get_navigation_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/get_navigation_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/integration/analysis/get_reachable_sources_test.dart b/pkg/analysis_server/test/integration/analysis/get_reachable_sources_test.dart
index 15309a6..0073bde 100644
--- a/pkg/analysis_server/test/integration/analysis/get_reachable_sources_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/get_reachable_sources_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:io';
 
 import 'package:test/test.dart';
diff --git a/pkg/analysis_server/test/integration/analysis/highlights_test.dart b/pkg/analysis_server/test/integration/analysis/highlights_test.dart
index c4c8fe2..cb5baf6 100644
--- a/pkg/analysis_server/test/integration/analysis/highlights_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/highlights_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
@@ -19,7 +17,7 @@
 
 @reflectiveTest
 class AnalysisHighlightsTest extends AbstractAnalysisServerIntegrationTest {
-  Map<HighlightRegionType, Set<String>> highlights;
+  late Map<HighlightRegionType, Set<String>> highlights;
 
   void check(HighlightRegionType type, List<String> expected) {
     expect(highlights[type], equals(expected.toSet()));
@@ -41,10 +39,7 @@
         var endIndex = startIndex + region.length;
         var highlightedText = text.substring(startIndex, endIndex);
         var type = region.type;
-        if (!highlights.containsKey(type)) {
-          highlights[type] = <String>{};
-        }
-        highlights[type].add(highlightedText);
+        highlights.putIfAbsent(type, () => {}).add(highlightedText);
       }
     });
     await analysisFinished;
@@ -52,8 +47,8 @@
 
   @override
   Future startServer({
-    int diagnosticPort,
-    int servicesPort,
+    int? diagnosticPort,
+    int? servicesPort,
   }) {
     return server.start(
         diagnosticPort: diagnosticPort,
diff --git a/pkg/analysis_server/test/integration/analysis/hint_sdk_version_async_exported_from_core_test.dart b/pkg/analysis_server/test/integration/analysis/hint_sdk_version_async_exported_from_core_test.dart
index 5398abf..38428ff 100644
--- a/pkg/analysis_server/test/integration/analysis/hint_sdk_version_async_exported_from_core_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/hint_sdk_version_async_exported_from_core_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/analysis/lint_test.dart b/pkg/analysis_server/test/integration/analysis/lint_test.dart
index 5b11ea0..a41d0f5 100644
--- a/pkg/analysis_server/test/integration/analysis/lint_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/lint_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analyzer/src/util/file_paths.dart' as file_paths;
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
@@ -50,7 +48,7 @@
     await analysisFinished;
 
     expect(currentAnalysisErrors[source], isList);
-    var errors = currentAnalysisErrors[source];
+    var errors = existingErrorsForFile(source);
     expect(errors, hasLength(1));
     var error = errors[0];
     expect(error.location.file, source);
diff --git a/pkg/analysis_server/test/integration/analysis/navigation_test.dart b/pkg/analysis_server/test/integration/analysis/navigation_test.dart
index 763097e..7d217d2 100644
--- a/pkg/analysis_server/test/integration/analysis/navigation_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/navigation_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
@@ -60,22 +58,19 @@
     sendAnalysisSetSubscriptions({
       AnalysisService.NAVIGATION: [pathname1]
     });
-    List<NavigationRegion> regions;
-    List<NavigationTarget> targets;
-    List<String> targetFiles;
-    onAnalysisNavigation.listen((AnalysisNavigationParams params) {
-      expect(params.file, equals(pathname1));
-      regions = params.regions;
-      targets = params.targets;
-      targetFiles = params.files;
-    });
-
-    await analysisFinished;
 
     // There should be a single error, due to the fact that 'dart:async' is not
     // used.
+    await analysisFinished;
     expect(currentAnalysisErrors[pathname1], hasLength(1));
     expect(currentAnalysisErrors[pathname2], isEmpty);
+
+    var params = await onAnalysisNavigation.first;
+    expect(params.file, equals(pathname1));
+    var regions = params.regions;
+    var targets = params.targets;
+    var targetFiles = params.files;
+
     NavigationTarget findTargetElement(int index) {
       for (var region in regions) {
         if (region.offset <= index && index < region.offset + region.length) {
diff --git a/pkg/analysis_server/test/integration/analysis/occurrences_test.dart b/pkg/analysis_server/test/integration/analysis/occurrences_test.dart
index 0332e23..e1b8d1c 100644
--- a/pkg/analysis_server/test/integration/analysis/occurrences_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/occurrences_test.dart
@@ -2,10 +2,7 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
-import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -19,7 +16,7 @@
 
 @reflectiveTest
 class OccurrencesTest extends AbstractAnalysisServerIntegrationTest {
-  Future<void> test_occurrences() {
+  Future<void> test_occurrences() async {
     var pathname = sourcePath('test.dart');
     var text = r'''
 main() {
@@ -37,33 +34,33 @@
     sendAnalysisSetSubscriptions({
       AnalysisService.OCCURRENCES: [pathname]
     });
-    List<Occurrences> occurrences;
-    onAnalysisOccurrences.listen((AnalysisOccurrencesParams params) {
-      expect(params.file, equals(pathname));
-      occurrences = params.occurrences;
-    });
-    return analysisFinished.then((_) {
-      expect(currentAnalysisErrors[pathname], isEmpty);
-      Set<int> findOffsets(String elementName) {
-        for (var occurrence in occurrences) {
-          if (occurrence.element.name == elementName) {
-            return occurrence.offsets.toSet();
-          }
+
+    await analysisFinished;
+    expect(currentAnalysisErrors[pathname], isEmpty);
+
+    var params = await onAnalysisOccurrences.first;
+    expect(params.file, equals(pathname));
+    var occurrences = params.occurrences;
+
+    Set<int> findOffsets(String elementName) {
+      for (var occurrence in occurrences) {
+        if (occurrence.element.name == elementName) {
+          return occurrence.offsets.toSet();
         }
-        fail('No element found matching $elementName');
       }
+      fail('No element found matching $elementName');
+    }
 
-      void check(String elementName, Iterable<String> expectedOccurrences) {
-        var expectedOffsets = expectedOccurrences
-            .map((String substring) => text.indexOf(substring))
-            .toSet();
-        var foundOffsets = findOffsets(elementName);
-        expect(foundOffsets, equals(expectedOffsets));
-      }
+    void check(String elementName, Iterable<String> expectedOccurrences) {
+      var expectedOffsets = expectedOccurrences
+          .map((String substring) => text.indexOf(substring))
+          .toSet();
+      var foundOffsets = findOffsets(elementName);
+      expect(foundOffsets, equals(expectedOffsets));
+    }
 
-      check('i', ['i = 0', 'i < 10', 'i++', 'i;']);
-      check('j', ['j = 0', 'j < i', 'j++', 'j;']);
-      check('sum', ['sum = 0', 'sum +=', 'sum)']);
-    });
+    check('i', ['i = 0', 'i < 10', 'i++', 'i;']);
+    check('j', ['j = 0', 'j < i', 'j++', 'j;']);
+    check('sum', ['sum = 0', 'sum +=', 'sum)']);
   }
 }
diff --git a/pkg/analysis_server/test/integration/analysis/outline_test.dart b/pkg/analysis_server/test/integration/analysis/outline_test.dart
index bc498f8..df5a0ea 100644
--- a/pkg/analysis_server/test/integration/analysis/outline_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/outline_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
@@ -19,7 +17,7 @@
 
 @reflectiveTest
 class OutlineTest extends AbstractAnalysisServerIntegrationTest {
-  Future<void> test_outline() {
+  Future<void> test_outline() async {
     var pathname = sourcePath('test.dart');
     var text = r'''
 class Class1 {
@@ -47,27 +45,26 @@
     sendAnalysisSetSubscriptions({
       AnalysisService.OUTLINE: [pathname]
     });
-    Outline outline;
-    onAnalysisOutline.listen((AnalysisOutlineParams params) {
-      expect(params.file, equals(pathname));
-      outline = params.outline;
-    });
-    return analysisFinished.then((_) {
-      expect(outline.element.kind, equals(ElementKind.COMPILATION_UNIT));
-      expect(outline.offset, equals(0));
-      expect(outline.length, equals(text.length));
-      var classes = outline.children;
-      expect(classes, hasLength(2));
-      expect(classes[0].element.name, equals('Class1'));
-      expect(classes[1].element.name, equals('Class2'));
 
-      var members = classes[0].children;
-      expect(members, hasLength(5));
-      expect(members[0].element.name, equals('field'));
-      expect(members[1].element.name, equals('method'));
-      expect(members[2].element.name, equals('staticMethod'));
-      expect(members[3].element.name, equals('getter'));
-      expect(members[4].element.name, equals('setter'));
-    });
+    var params = await onAnalysisOutline.first;
+    expect(params.file, equals(pathname));
+    var outline = params.outline;
+
+    expect(outline.element.kind, equals(ElementKind.COMPILATION_UNIT));
+    expect(outline.offset, equals(0));
+    expect(outline.length, equals(text.length));
+
+    var classes = outline.children!;
+    expect(classes, hasLength(2));
+    expect(classes[0].element.name, equals('Class1'));
+    expect(classes[1].element.name, equals('Class2'));
+
+    var members = classes[0].children!;
+    expect(members, hasLength(5));
+    expect(members[0].element.name, equals('field'));
+    expect(members[1].element.name, equals('method'));
+    expect(members[2].element.name, equals('staticMethod'));
+    expect(members[3].element.name, equals('getter'));
+    expect(members[4].element.name, equals('setter'));
   }
 }
diff --git a/pkg/analysis_server/test/integration/analysis/overrides_test.dart b/pkg/analysis_server/test/integration/analysis/overrides_test.dart
index 912ac03..0358bb4 100644
--- a/pkg/analysis_server/test/integration/analysis/overrides_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/overrides_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -18,7 +16,7 @@
 
 @reflectiveTest
 class OverridesTest extends AbstractAnalysisServerIntegrationTest {
-  Future<void> test_overrides() {
+  Future<void> test_overrides() async {
     var pathname = sourcePath('test.dart');
     var text = r'''
 abstract class Interface1 {
@@ -58,67 +56,69 @@
     sendAnalysisSetSubscriptions({
       AnalysisService.OVERRIDES: [pathname]
     });
-    List<Override> overrides;
-    onAnalysisOverrides.listen((AnalysisOverridesParams params) {
-      expect(params.file, equals(pathname));
-      overrides = params.overrides;
-    });
-    return analysisFinished.then((_) {
-      var targetOffset = text.indexOf('Target');
-      Override findOverride(String methodName) {
-        var methodOffset = text.indexOf(methodName, targetOffset);
-        for (var override in overrides) {
-          if (override.offset == methodOffset) {
-            return override;
-          }
-        }
-        return null;
-      }
 
-      void checkOverrides(String methodName, bool expectedOverridesBase,
-          List<String> expectedOverridesInterfaces) {
-        var override = findOverride(methodName);
-        if (!expectedOverridesBase && expectedOverridesInterfaces.isEmpty) {
-          // This method overrides nothing, so it should not appear in the
-          // overrides list.
-          expect(override, isNull);
-          return;
-        } else {
-          expect(override, isNotNull);
-        }
-        expect(override.length, equals(methodName.length));
-        var superclassMember = override.superclassMember;
-        if (expectedOverridesBase) {
-          expect(superclassMember.element.name, equals(methodName));
-          expect(superclassMember.className, equals('Base'));
-        } else {
-          expect(superclassMember, isNull);
-        }
-        var interfaceMembers = override.interfaceMembers;
-        if (expectedOverridesInterfaces.isNotEmpty) {
-          expect(interfaceMembers, isNotNull);
-          var actualOverridesInterfaces = <String>{};
-          for (var overriddenMember in interfaceMembers) {
-            expect(overriddenMember.element.name, equals(methodName));
-            var className = overriddenMember.className;
-            var wasAdded = actualOverridesInterfaces.add(className);
-            expect(wasAdded, isTrue);
-          }
-          expect(actualOverridesInterfaces,
-              equals(expectedOverridesInterfaces.toSet()));
-        } else {
-          expect(interfaceMembers, isNull);
+    var params = await onAnalysisOverrides.first;
+    expect(params.file, equals(pathname));
+    var overrides = params.overrides;
+
+    var targetOffset = text.indexOf('Target');
+
+    Override? findOverride(String methodName) {
+      var methodOffset = text.indexOf(methodName, targetOffset);
+      for (var override in overrides) {
+        if (override.offset == methodOffset) {
+          return override;
         }
       }
+      return null;
+    }
 
-      checkOverrides('method0', true, ['Interface1', 'Interface2']);
-      checkOverrides('method1', false, ['Interface1', 'Interface2']);
-      checkOverrides('method2', true, ['Interface1']);
-      checkOverrides('method3', false, ['Interface1']);
-      checkOverrides('method4', true, ['Interface2']);
-      checkOverrides('method5', false, ['Interface2']);
-      checkOverrides('method6', true, []);
-      checkOverrides('method7', false, []);
-    });
+    void checkOverrides(String methodName, bool expectedOverridesBase,
+        List<String> expectedOverridesInterfaces) {
+      var override = findOverride(methodName);
+
+      if (!expectedOverridesBase && expectedOverridesInterfaces.isEmpty) {
+        // This method overrides nothing, so it should not appear in the
+        // overrides list.
+        expect(override, isNull);
+        return;
+      } else {
+        override!;
+      }
+
+      expect(override.length, equals(methodName.length));
+      var superclassMember = override.superclassMember;
+      if (expectedOverridesBase) {
+        superclassMember!;
+        expect(superclassMember.element.name, equals(methodName));
+        expect(superclassMember.className, equals('Base'));
+      } else {
+        expect(superclassMember, isNull);
+      }
+      var interfaceMembers = override.interfaceMembers;
+      if (expectedOverridesInterfaces.isNotEmpty) {
+        interfaceMembers!;
+        var actualOverridesInterfaces = <String>{};
+        for (var overriddenMember in interfaceMembers) {
+          expect(overriddenMember.element.name, equals(methodName));
+          var className = overriddenMember.className;
+          var wasAdded = actualOverridesInterfaces.add(className);
+          expect(wasAdded, isTrue);
+        }
+        expect(actualOverridesInterfaces,
+            equals(expectedOverridesInterfaces.toSet()));
+      } else {
+        expect(interfaceMembers, isNull);
+      }
+    }
+
+    checkOverrides('method0', true, ['Interface1', 'Interface2']);
+    checkOverrides('method1', false, ['Interface1', 'Interface2']);
+    checkOverrides('method2', true, ['Interface1']);
+    checkOverrides('method3', false, ['Interface1']);
+    checkOverrides('method4', true, ['Interface2']);
+    checkOverrides('method5', false, ['Interface2']);
+    checkOverrides('method6', true, []);
+    checkOverrides('method7', false, []);
   }
 }
diff --git a/pkg/analysis_server/test/integration/analysis/package_root_test.dart b/pkg/analysis_server/test/integration/analysis/package_root_test.dart
index 6c7801b..3bb2096 100644
--- a/pkg/analysis_server/test/integration/analysis/package_root_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/package_root_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:path/path.dart' as path;
diff --git a/pkg/analysis_server/test/integration/analysis/reanalyze_concurrent_test.dart b/pkg/analysis_server/test/integration/analysis/reanalyze_concurrent_test.dart
index 7cf4371..1a42362 100644
--- a/pkg/analysis_server/test/integration/analysis/reanalyze_concurrent_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/reanalyze_concurrent_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 /// This test verifies that if reanalysis is performed while reanalysis is in
 /// progress, no problems occur.
 ///
diff --git a/pkg/analysis_server/test/integration/analysis/reanalyze_test.dart b/pkg/analysis_server/test/integration/analysis/reanalyze_test.dart
index ddfd145..6534bab 100644
--- a/pkg/analysis_server/test/integration/analysis/reanalyze_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/reanalyze_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -27,10 +25,9 @@
       // Make sure that reanalyze causes analysis to restart.
       var analysisRestarted = false;
       onServerStatus.listen((ServerStatusParams data) {
-        if (data.analysis != null) {
-          if (data.analysis.isAnalyzing) {
-            analysisRestarted = true;
-          }
+        var analysisStatus = data.analysis;
+        if (analysisStatus != null && analysisStatus.isAnalyzing) {
+          analysisRestarted = true;
         }
       });
       sendAnalysisReanalyze();
diff --git a/pkg/analysis_server/test/integration/analysis/set_analysis_roots_test.dart b/pkg/analysis_server/test/integration/analysis/set_analysis_roots_test.dart
index 2ef9e06..c8b991d 100644
--- a/pkg/analysis_server/test/integration/analysis/set_analysis_roots_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/set_analysis_roots_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/analysis/set_general_subscriptions_test.dart b/pkg/analysis_server/test/integration/analysis/set_general_subscriptions_test.dart
index 3523f2a..18cc929 100644
--- a/pkg/analysis_server/test/integration/analysis/set_general_subscriptions_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/set_general_subscriptions_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:path/path.dart' show join;
 import 'package:test/test.dart';
diff --git a/pkg/analysis_server/test/integration/analysis/set_priority_files_test.dart b/pkg/analysis_server/test/integration/analysis/set_priority_files_test.dart
index 01898a7..bc7b3e4 100644
--- a/pkg/analysis_server/test/integration/analysis/set_priority_files_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/set_priority_files_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -26,6 +24,7 @@
     await sendAnalysisSetPriorityFiles([pathname]);
 
     var status = await analysisFinished;
-    expect(status.analysis.isAnalyzing, false);
+    var analysisStatus = status.analysis;
+    expect(analysisStatus != null && analysisStatus.isAnalyzing, false);
   }
 }
diff --git a/pkg/analysis_server/test/integration/analysis/set_subscriptions_test.dart b/pkg/analysis_server/test/integration/analysis/set_subscriptions_test.dart
index bfb9365..d9d22d0 100644
--- a/pkg/analysis_server/test/integration/analysis/set_subscriptions_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/set_subscriptions_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/analysis/test_all.dart b/pkg/analysis_server/test/integration/analysis/test_all.dart
index 7bb5fd1..2e463f0 100644
--- a/pkg/analysis_server/test/integration/analysis/test_all.dart
+++ b/pkg/analysis_server/test/integration/analysis/test_all.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import 'analysis_options_test.dart' as analysis_options_test;
diff --git a/pkg/analysis_server/test/integration/analysis/update_content_list_test.dart b/pkg/analysis_server/test/integration/analysis/update_content_list_test.dart
index adb66f3..40c015c 100644
--- a/pkg/analysis_server/test/integration/analysis/update_content_list_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/update_content_list_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/integration/analysis/update_content_test.dart b/pkg/analysis_server/test/integration/analysis/update_content_test.dart
index 5760287..524b73c 100644
--- a/pkg/analysis_server/test/integration/analysis/update_content_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/update_content_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -78,7 +76,7 @@
     standardAnalysisSetup();
     await analysisFinished;
     expect(currentAnalysisErrors[pathname], isList);
-    var errors1 = currentAnalysisErrors[pathname];
+    var errors1 = existingErrorsForFile(pathname);
     expect(errors1, hasLength(1));
     expect(errors1[0].location.file, equals(pathname));
 
@@ -99,7 +97,7 @@
     });
     await analysisFinished;
     expect(currentAnalysisErrors[pathname], isList);
-    var errors2 = currentAnalysisErrors[pathname];
+    var errors2 = existingErrorsForFile(pathname);
     expect(errors2, hasLength(1));
     expect(errors2[0].location.file, equals(pathname));
   }
diff --git a/pkg/analysis_server/test/integration/analysis/update_options_test.dart b/pkg/analysis_server/test/integration/analysis/update_options_test.dart
index cd18c90..4864f2c 100644
--- a/pkg/analysis_server/test/integration/analysis/update_options_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/update_options_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/integration/analytics/enable_test.dart b/pkg/analysis_server/test/integration/analytics/enable_test.dart
index 0a7b44a..780810e 100644
--- a/pkg/analysis_server/test/integration/analytics/enable_test.dart
+++ b/pkg/analysis_server/test/integration/analytics/enable_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/analytics/is_enabled_test.dart b/pkg/analysis_server/test/integration/analytics/is_enabled_test.dart
index 721a495..0f86bfe 100644
--- a/pkg/analysis_server/test/integration/analytics/is_enabled_test.dart
+++ b/pkg/analysis_server/test/integration/analytics/is_enabled_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/analytics/send_event_test.dart b/pkg/analysis_server/test/integration/analytics/send_event_test.dart
index edf7c38..5f5aefe 100644
--- a/pkg/analysis_server/test/integration/analytics/send_event_test.dart
+++ b/pkg/analysis_server/test/integration/analytics/send_event_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import '../support/integration_tests.dart';
diff --git a/pkg/analysis_server/test/integration/analytics/send_timing_test.dart b/pkg/analysis_server/test/integration/analytics/send_timing_test.dart
index 6154b53..8e74028 100644
--- a/pkg/analysis_server/test/integration/analytics/send_timing_test.dart
+++ b/pkg/analysis_server/test/integration/analytics/send_timing_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import '../support/integration_tests.dart';
diff --git a/pkg/analysis_server/test/integration/analytics/test_all.dart b/pkg/analysis_server/test/integration/analytics/test_all.dart
index 3699d0c..4781bad 100644
--- a/pkg/analysis_server/test/integration/analytics/test_all.dart
+++ b/pkg/analysis_server/test/integration/analytics/test_all.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import 'enable_test.dart' as enable_test;
diff --git a/pkg/analysis_server/test/integration/completion/get_suggestions_test.dart b/pkg/analysis_server/test/integration/completion/get_suggestions_test.dart
index 8c982b5..ff29243 100644
--- a/pkg/analysis_server/test/integration/completion/get_suggestions_test.dart
+++ b/pkg/analysis_server/test/integration/completion/get_suggestions_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
@@ -19,17 +17,24 @@
 
 @reflectiveTest
 class GetSuggestionsTest extends AbstractAnalysisServerIntegrationTest {
-  String path;
-  String content;
-  int completionOffset;
+  bool initialized = false;
+  late String path;
+  late String content;
+  late int completionOffset;
 
   void setTestSource(String relPath, String content) {
+    if (initialized) {
+      fail('Call addTestUnit exactly once');
+    }
+
     path = sourcePath(relPath);
-    expect(completionOffset, isNull, reason: 'Call addTestUnit exactly once');
+
     completionOffset = content.indexOf('^');
     expect(completionOffset, isNot(equals(-1)), reason: 'missing ^');
+
     var nextOffset = content.indexOf('^', completionOffset + 1);
     expect(nextOffset, equals(-1), reason: 'too many ^');
+
     this.content = content.substring(0, completionOffset) +
         content.substring(completionOffset + 1);
   }
@@ -99,7 +104,7 @@
         (CompletionSuggestion suggestion) => suggestion.completion == 'length');
   }
 
-  Future<void> test_getSuggestions_sourceMissing_noWait() {
+  Future<void> test_getSuggestions_sourceMissing_noWait() async {
     path = sourcePath('does_not_exist.dart');
     // Do not write the file to "disk"
     //   writeFile(pathname, text);
@@ -107,11 +112,7 @@
     standardAnalysisSetup(subscribeStatus: false);
     // Missing file and no overlay
     //sendAnalysisUpdateContent({path: new AddContentOverlay(content)});
-    return sendCompletionGetSuggestions(path, 0).catchError((e) {
-      // Exception expected
-      return null;
-    }).then((result) {
-      expect(result, const TypeMatcher<CompletionGetSuggestionsResult>());
-    });
+    var result = await sendCompletionGetSuggestions(path, 0);
+    expect(result, const TypeMatcher<CompletionGetSuggestionsResult>());
   }
 }
diff --git a/pkg/analysis_server/test/integration/completion/test_all.dart b/pkg/analysis_server/test/integration/completion/test_all.dart
index 54aa987..857202f 100644
--- a/pkg/analysis_server/test/integration/completion/test_all.dart
+++ b/pkg/analysis_server/test/integration/completion/test_all.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import 'get_suggestions_test.dart' as get_suggestions;
diff --git a/pkg/analysis_server/test/integration/diagnostic/get_diagnostics_test.dart b/pkg/analysis_server/test/integration/diagnostic/get_diagnostics_test.dart
index 8b6fb64..84b84ae 100644
--- a/pkg/analysis_server/test/integration/diagnostic/get_diagnostics_test.dart
+++ b/pkg/analysis_server/test/integration/diagnostic/get_diagnostics_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/diagnostic/get_server_port_test.dart b/pkg/analysis_server/test/integration/diagnostic/get_server_port_test.dart
index 8efd679..42541e2 100644
--- a/pkg/analysis_server/test/integration/diagnostic/get_server_port_test.dart
+++ b/pkg/analysis_server/test/integration/diagnostic/get_server_port_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:convert';
 import 'dart:io';
 
diff --git a/pkg/analysis_server/test/integration/diagnostic/test_all.dart b/pkg/analysis_server/test/integration/diagnostic/test_all.dart
index 0b76085..50293e2 100644
--- a/pkg/analysis_server/test/integration/diagnostic/test_all.dart
+++ b/pkg/analysis_server/test/integration/diagnostic/test_all.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import 'get_diagnostics_test.dart' as get_diagnostics_test;
diff --git a/pkg/analysis_server/test/integration/edit/bulk_fixes_test.dart b/pkg/analysis_server/test/integration/edit/bulk_fixes_test.dart
index 0a9f574..4c4d82d 100644
--- a/pkg/analysis_server/test/integration/edit/bulk_fixes_test.dart
+++ b/pkg/analysis_server/test/integration/edit/bulk_fixes_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analyzer/src/util/file_paths.dart' as file_paths;
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/integration/edit/dartfix_test.dart b/pkg/analysis_server/test/integration/edit/dartfix_test.dart
index 1422a4c..7029973 100644
--- a/pkg/analysis_server/test/integration/edit/dartfix_test.dart
+++ b/pkg/analysis_server/test/integration/edit/dartfix_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/edit/format_test.dart b/pkg/analysis_server/test/integration/edit/format_test.dart
index 25975e3..081d9fc 100644
--- a/pkg/analysis_server/test/integration/edit/format_test.dart
+++ b/pkg/analysis_server/test/integration/edit/format_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/edit/get_assists_test.dart b/pkg/analysis_server/test/integration/edit/get_assists_test.dart
index de4bb79..015a385 100644
--- a/pkg/analysis_server/test/integration/edit/get_assists_test.dart
+++ b/pkg/analysis_server/test/integration/edit/get_assists_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/integration/edit/get_available_refactorings_test.dart b/pkg/analysis_server/test/integration/edit/get_available_refactorings_test.dart
index 08d3275..79b7389 100644
--- a/pkg/analysis_server/test/integration/edit/get_available_refactorings_test.dart
+++ b/pkg/analysis_server/test/integration/edit/get_available_refactorings_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/edit/get_dartfix_info_test.dart b/pkg/analysis_server/test/integration/edit/get_dartfix_info_test.dart
index a924cc3..3d3bf9f 100644
--- a/pkg/analysis_server/test/integration/edit/get_dartfix_info_test.dart
+++ b/pkg/analysis_server/test/integration/edit/get_dartfix_info_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/edit/get_fixes_test.dart b/pkg/analysis_server/test/integration/edit/get_fixes_test.dart
index f6ef4e9..6610ea2 100644
--- a/pkg/analysis_server/test/integration/edit/get_fixes_test.dart
+++ b/pkg/analysis_server/test/integration/edit/get_fixes_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/integration/edit/get_postfix_completion_test.dart b/pkg/analysis_server/test/integration/edit/get_postfix_completion_test.dart
index 356a4e6..db032ec 100644
--- a/pkg/analysis_server/test/integration/edit/get_postfix_completion_test.dart
+++ b/pkg/analysis_server/test/integration/edit/get_postfix_completion_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/integration/edit/get_refactoring_test.dart b/pkg/analysis_server/test/integration/edit/get_refactoring_test.dart
index a96db43..6896e4b 100644
--- a/pkg/analysis_server/test/integration/edit/get_refactoring_test.dart
+++ b/pkg/analysis_server/test/integration/edit/get_refactoring_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
@@ -52,12 +50,14 @@
     expect(result.optionsProblems, isEmpty);
     expect(result.finalProblems, isEmpty);
     expect(result.potentialEdits, isNull);
-    expect(result.change.edits, isNotEmpty);
+
+    var change = result.change!;
+    expect(change.edits, isNotEmpty);
+    var fileEdit = change.edits.first;
 
     // apply the refactoring, expect that the new code has no errors
-    var change = result.change;
-    expect(change.edits.first.edits, isNotEmpty);
-    for (var edit in change.edits.first.edits) {
+    expect(fileEdit.edits, isNotEmpty);
+    for (var edit in fileEdit.edits) {
       text = text.replaceRange(edit.offset, edit.end, edit.replacement);
     }
     await sendAnalysisUpdateContent({pathname: AddContentOverlay(text)});
diff --git a/pkg/analysis_server/test/integration/edit/get_statement_completion_test.dart b/pkg/analysis_server/test/integration/edit/get_statement_completion_test.dart
index 9f4465f..5c3ce3e 100644
--- a/pkg/analysis_server/test/integration/edit/get_statement_completion_test.dart
+++ b/pkg/analysis_server/test/integration/edit/get_statement_completion_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/integration/edit/import_elements_test.dart b/pkg/analysis_server/test/integration/edit/import_elements_test.dart
index f55d0ac..43ecb92 100644
--- a/pkg/analysis_server/test/integration/edit/import_elements_test.dart
+++ b/pkg/analysis_server/test/integration/edit/import_elements_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analyzer/file_system/physical_file_system.dart';
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
@@ -23,13 +21,13 @@
 class AnalysisGetImportElementsIntegrationTest
     extends AbstractAnalysisServerIntegrationTest {
   /// Pathname of the file containing Dart code.
-  String pathname;
+  late String pathname;
 
   /// Check that an edit.importElements request with the given list of
   /// [elements] produces the [expected] list of edits.
   Future<void> checkEdits(
       List<ImportedElements> elements, List<SourceEdit> expected,
-      {String expectedFile}) async {
+      {String? expectedFile}) async {
     bool equals(SourceEdit actualEdit, SourceEdit expectedEdit) {
       return actualEdit.offset == expectedEdit.offset &&
           actualEdit.length == expectedEdit.length &&
@@ -48,8 +46,7 @@
 
     var result = await sendEditImportElements(pathname, elements);
 
-    var edit = result.edit;
-    expect(edit, isNotNull);
+    var edit = result.edit!;
     if (expectedFile == null) {
       expect(edit.file, pathname);
     } else {
diff --git a/pkg/analysis_server/test/integration/edit/is_postfix_completion_applicable_test.dart b/pkg/analysis_server/test/integration/edit/is_postfix_completion_applicable_test.dart
index 5a4620b..af423d1 100644
--- a/pkg/analysis_server/test/integration/edit/is_postfix_completion_applicable_test.dart
+++ b/pkg/analysis_server/test/integration/edit/is_postfix_completion_applicable_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/edit/list_postfix_completion_templates_test.dart b/pkg/analysis_server/test/integration/edit/list_postfix_completion_templates_test.dart
index 1af3946..21f950d 100644
--- a/pkg/analysis_server/test/integration/edit/list_postfix_completion_templates_test.dart
+++ b/pkg/analysis_server/test/integration/edit/list_postfix_completion_templates_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
diff --git a/pkg/analysis_server/test/integration/edit/organize_directives_test.dart b/pkg/analysis_server/test/integration/edit/organize_directives_test.dart
index c43c5ee..2bf4c1f 100644
--- a/pkg/analysis_server/test/integration/edit/organize_directives_test.dart
+++ b/pkg/analysis_server/test/integration/edit/organize_directives_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/edit/sort_members_test.dart b/pkg/analysis_server/test/integration/edit/sort_members_test.dart
index bba0bc6..a49aca3 100644
--- a/pkg/analysis_server/test/integration/edit/sort_members_test.dart
+++ b/pkg/analysis_server/test/integration/edit/sort_members_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/edit/test_all.dart b/pkg/analysis_server/test/integration/edit/test_all.dart
index e61e3b7..5c3a653 100644
--- a/pkg/analysis_server/test/integration/edit/test_all.dart
+++ b/pkg/analysis_server/test/integration/edit/test_all.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import 'bulk_fixes_test.dart' as bulk_fixes_test;
diff --git a/pkg/analysis_server/test/integration/execution/create_context_test.dart b/pkg/analysis_server/test/integration/execution/create_context_test.dart
index 3a938cd..563e405 100644
--- a/pkg/analysis_server/test/integration/execution/create_context_test.dart
+++ b/pkg/analysis_server/test/integration/execution/create_context_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/execution/delete_context_test.dart b/pkg/analysis_server/test/integration/execution/delete_context_test.dart
index 0e84d3e..4087c06 100644
--- a/pkg/analysis_server/test/integration/execution/delete_context_test.dart
+++ b/pkg/analysis_server/test/integration/execution/delete_context_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/execution/map_uri_test.dart b/pkg/analysis_server/test/integration/execution/map_uri_test.dart
index 1efe500..a5a200b 100644
--- a/pkg/analysis_server/test/integration/execution/map_uri_test.dart
+++ b/pkg/analysis_server/test/integration/execution/map_uri_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -23,8 +21,7 @@
     writeFile(sourcePath('.packages'), 'foo:lib/');
     standardAnalysisSetup();
 
-    var contextId =
-        (await sendExecutionCreateContext(sourceDirectory.path))?.id;
+    var contextId = (await sendExecutionCreateContext(sourceDirectory.path)).id;
 
     {
       var result =
diff --git a/pkg/analysis_server/test/integration/execution/set_subscriptions_test.dart b/pkg/analysis_server/test/integration/execution/set_subscriptions_test.dart
index 3e328f2..340ded4 100644
--- a/pkg/analysis_server/test/integration/execution/set_subscriptions_test.dart
+++ b/pkg/analysis_server/test/integration/execution/set_subscriptions_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/execution/test_all.dart b/pkg/analysis_server/test/integration/execution/test_all.dart
index 9214e0d..76aa11d 100644
--- a/pkg/analysis_server/test/integration/execution/test_all.dart
+++ b/pkg/analysis_server/test/integration/execution/test_all.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import 'create_context_test.dart' as create_context_test;
diff --git a/pkg/analysis_server/test/integration/linter/lint_names_test.dart b/pkg/analysis_server/test/integration/linter/lint_names_test.dart
index cc57c3d..e30881f 100644
--- a/pkg/analysis_server/test/integration/linter/lint_names_test.dart
+++ b/pkg/analysis_server/test/integration/linter/lint_names_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:io';
 
 import 'package:analyzer/dart/analysis/features.dart';
@@ -18,7 +16,6 @@
 import 'package:analyzer/src/lint/registry.dart';
 import 'package:analyzer/src/string_source.dart';
 import 'package:linter/src/rules.dart';
-import 'package:meta/meta.dart';
 import 'package:path/path.dart' as path;
 import 'package:test/test.dart';
 
@@ -50,22 +47,24 @@
   });
 }
 
-List<LintRule> _registeredLints;
+List<LintRule>? _registeredLints;
 
 Iterable<String> get registeredLintNames => registeredLints.map((r) => r.name);
 
 List<LintRule> get registeredLints {
-  if (_registeredLints == null) {
+  var registeredLints = _registeredLints;
+  if (registeredLints == null) {
     if (Registry.ruleRegistry.isEmpty) {
       registerLintRules();
     }
-    _registeredLints = Registry.ruleRegistry.toList();
+    registeredLints = Registry.ruleRegistry.toList();
+    _registeredLints = registeredLints;
   }
-  return _registeredLints;
+  return registeredLints;
 }
 
 class CompilationUnitParser {
-  CompilationUnit parse({@required String contents, @required String name}) {
+  CompilationUnit parse({required String contents, required String name}) {
     var reader = CharSequenceReader(contents);
     var stringSource = StringSource(contents, name);
     var errorListener = _ErrorListener();
diff --git a/pkg/analysis_server/test/integration/linter/test_all.dart b/pkg/analysis_server/test/integration/linter/test_all.dart
index 833b9ae..addcf98 100644
--- a/pkg/analysis_server/test/integration/linter/test_all.dart
+++ b/pkg/analysis_server/test/integration/linter/test_all.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import 'lint_names_test.dart' as lint_names;
diff --git a/pkg/analysis_server/test/integration/search/find_element_references_test.dart b/pkg/analysis_server/test/integration/search/find_element_references_test.dart
index f74346b..aab63ee 100644
--- a/pkg/analysis_server/test/integration/search/find_element_references_test.dart
+++ b/pkg/analysis_server/test/integration/search/find_element_references_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -18,7 +16,7 @@
 
 @reflectiveTest
 class FindElementReferencesTest extends AbstractAnalysisServerIntegrationTest {
-  String pathname;
+  late String pathname;
 
   Future<void> test_badTarget() async {
     var text = r'''
@@ -52,7 +50,7 @@
     standardAnalysisSetup();
     await analysisFinished;
 
-    var results = await _findElementReferences(text);
+    var results = (await _findElementReferences(text))!;
     expect(results, hasLength(1));
     var result = results.first;
     expect(result.location.file, pathname);
@@ -61,7 +59,7 @@
     expect(result.path.first.name, 'main');
   }
 
-  Future<List<SearchResult>> _findElementReferences(String text) async {
+  Future<List<SearchResult>?> _findElementReferences(String text) async {
     var offset = text.indexOf(' /* target */') - 1;
     var result = await sendSearchFindElementReferences(pathname, offset, false);
     if (result.id == null) return null;
diff --git a/pkg/analysis_server/test/integration/search/find_member_declarations_test.dart b/pkg/analysis_server/test/integration/search/find_member_declarations_test.dart
index 71d4557..f8f65cf 100644
--- a/pkg/analysis_server/test/integration/search/find_member_declarations_test.dart
+++ b/pkg/analysis_server/test/integration/search/find_member_declarations_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -18,8 +16,6 @@
 
 @reflectiveTest
 class FindMemberDeclarationsTest extends AbstractAnalysisServerIntegrationTest {
-  String pathname;
-
   Future<void> test_findMemberDeclarations() async {
     var text = r'''
 String qux() => 'qux';
@@ -30,7 +26,7 @@
 }
 ''';
 
-    pathname = sourcePath('foo.dart');
+    var pathname = sourcePath('foo.dart');
     writeFile(pathname, text);
     standardAnalysisSetup();
     await analysisFinished;
diff --git a/pkg/analysis_server/test/integration/search/find_member_references_test.dart b/pkg/analysis_server/test/integration/search/find_member_references_test.dart
index 209c1ec..176a205 100644
--- a/pkg/analysis_server/test/integration/search/find_member_references_test.dart
+++ b/pkg/analysis_server/test/integration/search/find_member_references_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -18,8 +16,6 @@
 
 @reflectiveTest
 class FindMemberReferencesTest extends AbstractAnalysisServerIntegrationTest {
-  String pathname;
-
   Future<void> test_findMemberReferences() async {
     var text = r'''
 String qux() => 'qux';
@@ -30,7 +26,7 @@
 }
 ''';
 
-    pathname = sourcePath('foo.dart');
+    var pathname = sourcePath('foo.dart');
     writeFile(pathname, text);
     standardAnalysisSetup();
     await analysisFinished;
diff --git a/pkg/analysis_server/test/integration/search/find_top_level_declarations_test.dart b/pkg/analysis_server/test/integration/search/find_top_level_declarations_test.dart
index 8185e1a..4ea563b 100644
--- a/pkg/analysis_server/test/integration/search/find_top_level_declarations_test.dart
+++ b/pkg/analysis_server/test/integration/search/find_top_level_declarations_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
@@ -19,8 +17,6 @@
 @reflectiveTest
 class FindTopLevelDeclarationsTest
     extends AbstractAnalysisServerIntegrationTest {
-  String pathname;
-
   Future<void> test_findTopLevelDeclarations() async {
     var text = r'''
 String qux() => 'qux';
@@ -31,7 +27,7 @@
 }
 ''';
 
-    pathname = sourcePath('foo.dart');
+    var pathname = sourcePath('foo.dart');
     writeFile(pathname, text);
     standardAnalysisSetup();
     await analysisFinished;
diff --git a/pkg/analysis_server/test/integration/search/get_type_hierarchy_test.dart b/pkg/analysis_server/test/integration/search/get_type_hierarchy_test.dart
index 5c5c6d5..acc839e 100644
--- a/pkg/analysis_server/test/integration/search/get_type_hierarchy_test.dart
+++ b/pkg/analysis_server/test/integration/search/get_type_hierarchy_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:analysis_server/protocol/protocol_generated.dart';
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:test/test.dart';
@@ -20,9 +18,9 @@
 @reflectiveTest
 class GetTypeHierarchyTest extends AbstractAnalysisServerIntegrationTest {
   /// Pathname of the main file to run tests in.
-  String pathname;
+  late String pathname;
 
-  Future getTypeHierarchy_badTarget() {
+  Future getTypeHierarchy_badTarget() async {
     var text = r'''
 main() {
   if /* target */ (true) {
@@ -30,12 +28,11 @@
   }
 }
 ''';
-    return typeHierarchyTest(text).then((HierarchyResults results) {
-      expect(results, isNull);
-    });
+    var results = await typeHierarchyTestNullable(text);
+    expect(results, isNull);
   }
 
-  Future getTypeHierarchy_classElement() {
+  Future<void> getTypeHierarchy_classElement() {
     var text = r'''
 class Base {}
 class Pivot /* target */ extends Base {}
@@ -47,11 +44,12 @@
       void checkElement(String name) {
         // We don't check the full element data structure; just enough to make
         // sure that we're pointing to the correct element.
-        var element = results.items[results.nameToIndex[name]].classElement;
+        // var element = results.items[results.nameToIndex[name]].classElement;
+        var element = results.getItem(name).classElement;
         expect(element.kind, equals(ElementKind.CLASS));
         expect(element.name, equals(name));
         if (name != 'Object') {
-          expect(element.location.offset,
+          expect(element.location!.offset,
               equals(text.indexOf('class $name') + 'class '.length));
         }
       }
@@ -76,14 +74,13 @@
     });
   }
 
-  Future getTypeHierarchy_functionTarget() {
+  Future getTypeHierarchy_functionTarget() async {
     var text = r'''
 main /* target */ () {
 }
 ''';
-    return typeHierarchyTest(text).then((HierarchyResults results) {
-      expect(results, isNull);
-    });
+    var results = await typeHierarchyTestNullable(text);
+    expect(results, isNull);
   }
 
   Future getTypeHierarchy_interfaces() {
@@ -121,13 +118,13 @@
     return typeHierarchyTest(text).then((HierarchyResults results) {
       expect(results.items, hasLength(6));
       expect(results.getItem('Object').memberElement, isNull);
-      expect(results.getItem('Base1').memberElement.location.offset,
+      expect(results.getItem('Base1').memberElement!.location!.offset,
           equals(text.indexOf('foo /* base1 */')));
       expect(results.getItem('Base2').memberElement, isNull);
-      expect(results.getItem('Pivot').memberElement.location.offset,
+      expect(results.getItem('Pivot').memberElement!.location!.offset,
           equals(text.indexOf('foo /* target */')));
       expect(results.getItem('Derived1').memberElement, isNull);
-      expect(results.getItem('Derived2').memberElement.location.offset,
+      expect(results.getItem('Derived2').memberElement!.location!.offset,
           equals(text.indexOf('foo /* derived2 */')));
     });
   }
@@ -191,7 +188,7 @@
     });
   }
 
-  Future<void> test_getTypeHierarchy() {
+  Future<void> test_getTypeHierarchy() async {
     pathname = sourcePath('test.dart');
     // Write a dummy file which will be overridden by tests using
     // [sendAnalysisUpdateContent].
@@ -200,30 +197,34 @@
 
     // Run all the getTypeHierarchy tests at once so that the server can take
     // advantage of incremental analysis and the test doesn't time out.
-    var tests = [
-      getTypeHierarchy_classElement,
-      getTypeHierarchy_displayName,
-      getTypeHierarchy_memberElement,
-      getTypeHierarchy_superclass,
-      getTypeHierarchy_interfaces,
-      getTypeHierarchy_mixins,
-      getTypeHierarchy_subclasses,
-      getTypeHierarchy_badTarget,
-      getTypeHierarchy_functionTarget
-    ];
-    return Future.forEach(tests, (test) => test());
+    await getTypeHierarchy_classElement();
+    await getTypeHierarchy_displayName();
+    await getTypeHierarchy_memberElement();
+    await getTypeHierarchy_superclass();
+    await getTypeHierarchy_interfaces();
+    await getTypeHierarchy_mixins();
+    await getTypeHierarchy_subclasses();
+    await getTypeHierarchy_badTarget();
+    await getTypeHierarchy_functionTarget();
   }
 
   Future<HierarchyResults> typeHierarchyTest(String text) async {
+    var results = (await typeHierarchyTestNullable(text))!;
+    return results;
+  }
+
+  Future<HierarchyResults?> typeHierarchyTestNullable(String text) async {
     var offset = text.indexOf(' /* target */') - 1;
     sendAnalysisUpdateContent({pathname: AddContentOverlay(text)});
     await analysisFinished;
     var result = await sendSearchGetTypeHierarchy(pathname, offset);
-    if (result.hierarchyItems == null) {
+
+    var hierarchyItems = result.hierarchyItems;
+    if (hierarchyItems == null) {
       return null;
-    } else {
-      return HierarchyResults(result.hierarchyItems);
     }
+
+    return HierarchyResults(hierarchyItems);
   }
 }
 
@@ -234,16 +235,14 @@
 
   /// The first hierarchy item from the result, which represents the pivot
   /// class.
-  TypeHierarchyItem pivot;
+  final TypeHierarchyItem pivot;
 
   /// A map from element name to item index.
-  Map<String, int> nameToIndex;
+  final Map<String, int> nameToIndex = {};
 
   /// Create a [HierarchyResults] object based on the result from a
   /// getTypeHierarchy request.
-  HierarchyResults(this.items) {
-    pivot = items[0];
-    nameToIndex = <String, int>{};
+  HierarchyResults(this.items) : pivot = items[0] {
     for (var i = 0; i < items.length; i++) {
       nameToIndex[items[i].classElement.name] = i;
     }
@@ -251,8 +250,9 @@
 
   /// Get an item by class name.
   TypeHierarchyItem getItem(String name) {
-    if (nameToIndex.containsKey(name)) {
-      return items[nameToIndex[name]];
+    var index = nameToIndex[name];
+    if (index != null) {
+      return items[index];
     } else {
       fail('Class $name not found in hierarchy results');
     }
diff --git a/pkg/analysis_server/test/integration/search/test_all.dart b/pkg/analysis_server/test/integration/search/test_all.dart
index e95e3f5..b39f490 100644
--- a/pkg/analysis_server/test/integration/search/test_all.dart
+++ b/pkg/analysis_server/test/integration/search/test_all.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import 'find_element_references_test.dart' as find_element_references_test;
diff --git a/pkg/analysis_server/test/integration/server/bazel_changes_test.dart b/pkg/analysis_server/test/integration/server/bazel_changes_test.dart
index 9b64519..f904df3 100644
--- a/pkg/analysis_server/test/integration/server/bazel_changes_test.dart
+++ b/pkg/analysis_server/test/integration/server/bazel_changes_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:async';
 import 'dart:io';
 
@@ -32,15 +30,15 @@
   /// Path to the `command.log` file.
   ///
   /// Writing to it should trigger our change detection to run.
-  String commandLogPath;
+  late String commandLogPath;
 
-  String bazelRoot;
-  String tmpPath;
-  String workspacePath;
-  String bazelOutPath;
-  String bazelBinPath;
-  String bazelGenfilesPath;
-  Directory oldSourceDirectory;
+  late String bazelRoot;
+  late String tmpPath;
+  late String workspacePath;
+  late String bazelOutPath;
+  late String bazelBinPath;
+  late String bazelGenfilesPath;
+  late Directory oldSourceDirectory;
 
   String inTmpDir(String relative) =>
       path.join(tmpPath, relative.replaceAll('/', path.separator));
diff --git a/pkg/analysis_server/test/integration/server/get_version_test.dart b/pkg/analysis_server/test/integration/server/get_version_test.dart
index d1c3428..a82ea75 100644
--- a/pkg/analysis_server/test/integration/server/get_version_test.dart
+++ b/pkg/analysis_server/test/integration/server/get_version_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import '../support/integration_tests.dart';
diff --git a/pkg/analysis_server/test/integration/server/set_subscriptions_invalid_service_test.dart b/pkg/analysis_server/test/integration/server/set_subscriptions_invalid_service_test.dart
index f25b46c..ce2abe6 100644
--- a/pkg/analysis_server/test/integration/server/set_subscriptions_invalid_service_test.dart
+++ b/pkg/analysis_server/test/integration/server/set_subscriptions_invalid_service_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
@@ -18,15 +16,13 @@
 @reflectiveTest
 class SetSubscriptionsInvalidTest
     extends AbstractAnalysisServerIntegrationTest {
-  Future<void> test_setSubscriptions_invalidService() {
+  Future<void> test_setSubscriptions_invalidService() async {
     // TODO(paulberry): verify that if an invalid service is specified, the
     // current subscriptions are unchanged.
-    return server.send('server.setSubscriptions', {
-      'subscriptions': ['bogus']
-    }).then((_) {
-      fail('setSubscriptions should have produced an error');
-    }, onError: (error) {
-      // The expected error occurred.
-    });
+    expect(() async {
+      await server.send('server.setSubscriptions', {
+        'subscriptions': ['bogus']
+      });
+    }, throwsA(const TypeMatcher<ServerErrorMessage>()));
   }
 }
diff --git a/pkg/analysis_server/test/integration/server/set_subscriptions_test.dart b/pkg/analysis_server/test/integration/server/set_subscriptions_test.dart
index 2ea390e..9a7078b 100644
--- a/pkg/analysis_server/test/integration/server/set_subscriptions_test.dart
+++ b/pkg/analysis_server/test/integration/server/set_subscriptions_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:async';
 
 import 'package:analysis_server/protocol/protocol_generated.dart';
diff --git a/pkg/analysis_server/test/integration/server/shutdown_test.dart b/pkg/analysis_server/test/integration/server/shutdown_test.dart
index cee3a55..a14e573 100644
--- a/pkg/analysis_server/test/integration/server/shutdown_test.dart
+++ b/pkg/analysis_server/test/integration/server/shutdown_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test/test.dart';
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
diff --git a/pkg/analysis_server/test/integration/server/status_test.dart b/pkg/analysis_server/test/integration/server/status_test.dart
index 020b6b64..0588e16 100644
--- a/pkg/analysis_server/test/integration/server/status_test.dart
+++ b/pkg/analysis_server/test/integration/server/status_test.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:async';
 
 import 'package:analysis_server/protocol/protocol_generated.dart';
@@ -27,8 +25,9 @@
     var analysisBegun = Completer();
     var analysisFinished = Completer();
     onServerStatus.listen((ServerStatusParams params) {
-      if (params.analysis != null) {
-        if (params.analysis.isAnalyzing) {
+      var analysisStatus = params.analysis;
+      if (analysisStatus != null) {
+        if (analysisStatus.isAnalyzing) {
           expect(analysisBegun.isCompleted, isFalse);
           analysisBegun.complete();
         } else {
diff --git a/pkg/analysis_server/test/integration/server/test_all.dart b/pkg/analysis_server/test/integration/server/test_all.dart
index cc55441..92ae2b1 100644
--- a/pkg/analysis_server/test/integration/server/test_all.dart
+++ b/pkg/analysis_server/test/integration/server/test_all.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'package:test_reflective_loader/test_reflective_loader.dart';
 
 import 'bazel_changes_test.dart' as bazel_changes_test;
diff --git a/pkg/analysis_server/test/integration/support/integration_tests.dart b/pkg/analysis_server/test/integration/support/integration_tests.dart
index 3f768be..b135280 100644
--- a/pkg/analysis_server/test/integration/support/integration_tests.dart
+++ b/pkg/analysis_server/test/integration/support/integration_tests.dart
@@ -139,6 +139,16 @@
     server.debugStdio();
   }
 
+  /// If there was a set of errors (might be empty) received for the file
+  /// with the given [path], return it. If no errors - fail.
+  List<AnalysisError> existingErrorsForFile(String path) {
+    var errors = currentAnalysisErrors[path];
+    if (errors == null) {
+      fail('Expected errors for: $path');
+    }
+    return errors;
+  }
+
   List<AnalysisError>? getErrors(String pathname) =>
       currentAnalysisErrors[pathname];
 
@@ -390,8 +400,7 @@
   /// Commands that have been sent to the server but not yet acknowledged, and
   /// the [Completer] objects which should be completed when acknowledgement is
   /// received.
-  final Map<String, Completer<Map<String, dynamic>>> _pendingCommands =
-      <String, Completer<Map<String, dynamic>>>{};
+  final Map<String, Completer<Map<String, Object?>?>> _pendingCommands = {};
 
   /// Number which should be used to compute the 'id' to send in the next
   /// command sent to the server.
@@ -538,14 +547,14 @@
   /// normal (non-error) response, the future will be completed with the
   /// 'result' field from the response.  If the server acknowledges the command
   /// with an error response, the future will be completed with an error.
-  Future<Map<String, dynamic>> send(
-      String method, Map<String, dynamic>? params) {
+  Future<Map<String, Object?>?> send(
+      String method, Map<String, Object?>? params) {
     var id = '${_nextId++}';
-    var command = <String, dynamic>{'id': id, 'method': method};
+    var command = <String, Object?>{'id': id, 'method': method};
     if (params != null) {
       command['params'] = params;
     }
-    var completer = Completer<Map<String, dynamic>>();
+    var completer = Completer<Map<String, Object?>?>();
     _pendingCommands[id] = completer;
     var line = json.encode(command);
     _recordStdio('==> $line');
diff --git a/pkg/analysis_server/tool/code_completion/code_metrics.dart b/pkg/analysis_server/tool/code_completion/code_metrics.dart
index 43bf25b5..27585c6 100644
--- a/pkg/analysis_server/tool/code_completion/code_metrics.dart
+++ b/pkg/analysis_server/tool/code_completion/code_metrics.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:io' as io;
 
 import 'package:analyzer/dart/analysis/analysis_context_collection.dart';
@@ -52,7 +50,7 @@
 }
 
 /// Print usage information for this tool.
-void printUsage(ArgParser parser, {String error}) {
+void printUsage(ArgParser parser, {String? error}) {
   if (error != null) {
     print(error);
     print('');
@@ -112,7 +110,7 @@
   /// Record that an element of the given [node] was found in the given
   /// [context].
   void recordNode(String nodeClassName, String property, AstNode node) {
-    var childClass = node?.runtimeType?.toString() ?? 'null';
+    var childClass = node.runtimeType.toString();
     if (childClass.endsWith('Impl')) {
       childClass = childClass.substring(0, childClass.length - 4);
     }
@@ -136,7 +134,7 @@
     classMap[parentClassName] = (classMap[parentClassName] ?? 0) + 1;
   }
 
-  void recordToken(String nodeClassName, String property, Token token) {
+  void recordToken(String nodeClassName, String property, Token? token) {
     var lexeme = token?.lexeme ?? 'null';
     _recordChildData(nodeClassName, property, lexeme);
   }
@@ -1313,7 +1311,7 @@
   /// Visit the children of a node. The node is an instance of the class named
   /// [parentClass] and the children are in the [childMap], keyed by the name of
   /// the child property.
-  void _visitChildren(AstNode node, Map<String, Object> childMap) {
+  void _visitChildren(AstNode node, Map<String, Object?> childMap) {
     var nodeClassName = _className(node);
 
     data.recordNodeClass(nodeClassName);
@@ -1333,7 +1331,7 @@
       } else if (child is NodeList) {
         data.recordNodeList(nodeClassName, property, child);
         visitChildren.addAll(child);
-      } else if (child is Token || child == null) {
+      } else if (child is Token?) {
         data.recordToken(nodeClassName, property, child);
       } else {
         throw ArgumentError('Unknown class of child: ${child.runtimeType}');
@@ -1413,7 +1411,7 @@
             continue;
           }
 
-          resolvedUnitResult.unit.accept(collector);
+          resolvedUnitResult.unit!.accept(collector);
         } catch (exception) {
           print('Exception caught analyzing: "$filePath"');
           print(exception.toString());
@@ -1426,9 +1424,6 @@
   /// column occupied by the map.
   List<String> _convertMap<T extends Object>(String context, Map<T, int> map) {
     var columns = <String>[];
-    if (map == null) {
-      return columns;
-    }
     var entries = map.entries.toList()
       ..sort((first, second) {
         return second.value.compareTo(first.value);
diff --git a/pkg/analysis_server/tool/code_completion/corpus.dart b/pkg/analysis_server/tool/code_completion/corpus.dart
index c8651ce..2bde6fe 100644
--- a/pkg/analysis_server/tool/code_completion/corpus.dart
+++ b/pkg/analysis_server/tool/code_completion/corpus.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:convert';
 import 'dart:io';
 
@@ -67,8 +65,8 @@
 final _client = http.Client();
 
 final _homeDir = Platform.isWindows
-    ? Platform.environment['LOCALAPPDATA']
-    : Platform.environment['HOME'];
+    ? Platform.environment['LOCALAPPDATA']!
+    : Platform.environment['HOME']!;
 
 final _package_config = path.join('.dart_tool', 'package_config.json');
 
@@ -143,7 +141,13 @@
     final entries = doc.querySelectorAll('entry');
     for (var entry in entries) {
       final link = entry.querySelector('link');
+      if (link == null) {
+        continue;
+      }
       final href = link.attributes['href'];
+      if (href == null) {
+        continue;
+      }
       final body = await _getBody(href);
       final doc = parse(body);
       final links = doc.querySelectorAll('a');
diff --git a/pkg/analysis_server/tool/code_completion/flutter_metrics.dart b/pkg/analysis_server/tool/code_completion/flutter_metrics.dart
index fb211d0..9942472 100644
--- a/pkg/analysis_server/tool/code_completion/flutter_metrics.dart
+++ b/pkg/analysis_server/tool/code_completion/flutter_metrics.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:io' as io;
 
 import 'package:analysis_server/src/utilities/flutter.dart';
@@ -52,7 +50,7 @@
 }
 
 /// Print usage information for this tool.
-void printUsage(ArgParser parser, {String error}) {
+void printUsage(ArgParser parser, {String? error}) {
   if (error != null) {
     print(error);
     print('');
@@ -106,7 +104,7 @@
   /// Record that an instance of the [childWidget] was created. If the instance
   /// creation expression is an argument in another widget constructor
   /// invocation, then the [parentWidget] is the name of the enclosing class.
-  void recordWidgetCreation(String childWidget, String parentWidget) {
+  void recordWidgetCreation(String childWidget, String? parentWidget) {
     totalWidgetCount++;
     widgetCounts[childWidget] = (widgetCounts[childWidget] ?? 0) + 1;
 
@@ -127,11 +125,11 @@
   final FlutterData data;
 
   /// The object used to determine Flutter-specific features.
-  Flutter flutter;
+  final Flutter flutter = Flutter.instance;
 
   /// The name of the most deeply widget class whose constructor invocation we
   /// are within.
-  String parentWidget;
+  String? parentWidget;
 
   /// Initialize a newly created collector to add data points to the given
   /// [data].
@@ -213,11 +211,7 @@
           //
           // Check for errors that cause the file to be skipped.
           //
-          if (resolvedUnitResult == null) {
-            print('');
-            print('File $filePath skipped because of an internal error.');
-            continue;
-          } else if (resolvedUnitResult.state != ResultState.VALID) {
+          if (resolvedUnitResult.state != ResultState.VALID) {
             print('');
             print('File $filePath skipped because it could not be analyzed.');
             continue;
@@ -230,8 +224,7 @@
             continue;
           }
 
-          collector.flutter = Flutter.instance;
-          resolvedUnitResult.unit.accept(collector);
+          resolvedUnitResult.unit!.accept(collector);
         } catch (exception, stackTrace) {
           print('');
           print('Exception caught analyzing: "$filePath"');
@@ -270,13 +263,15 @@
   /// Write the structure data in the [structureMap] to the [sink].
   void _writeStructureData(
       StringSink sink, Map<String, Map<String, int>> structureMap) {
-    var outerKeys = structureMap.keys.toList()..sort();
-    for (var outerKey in outerKeys) {
+    var outerEntries = structureMap.entries.toList();
+    outerEntries.sort((first, second) => first.key.compareTo(second.key));
+    for (var outerEntry in outerEntries) {
+      var outerKey = outerEntry.key;
       sink.writeln(outerKey);
-      var innerMap = structureMap[outerKey];
+      var innerMap = outerEntry.value;
       var entries = innerMap.entries.toList();
       entries.sort((first, second) => second.value.compareTo(first.value));
-      var total = entries.fold(
+      var total = entries.fold<int>(
           0, (previousValue, entry) => previousValue + entry.value);
       for (var entry in entries) {
         var percent = _formatPercent(entry.value, total);
diff --git a/pkg/analysis_server/tool/instrumentation/log/log.dart b/pkg/analysis_server/tool/instrumentation/log/log.dart
index ea4968d..503f991 100644
--- a/pkg/analysis_server/tool/instrumentation/log/log.dart
+++ b/pkg/analysis_server/tool/instrumentation/log/log.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 /// A representation of the contents of an instrumentation log.
 import 'dart:convert';
 import 'dart:math' as math;
@@ -53,7 +51,7 @@
 
   /// Return the entry group with the given [id], or `null` if there is no group
   /// with the given id.
-  static EntryGroup withId(String id) {
+  static EntryGroup? withId(String id) {
     for (var group in groups) {
       if (group.id == id) {
         return group;
@@ -137,7 +135,7 @@
   List<String> logFilePaths;
 
   /// The entries in the instrumentation log.
-  List<LogEntry> logEntries;
+  late List<LogEntry> logEntries;
 
   /// A table mapping the entry groups that have been computed to the list of
   /// entries in that group.
@@ -171,7 +169,7 @@
 
   /// The ranges of entries that are between analysis start and analysis end
   /// notifications.
-  List<EntryRange> analysisRanges;
+  late List<EntryRange> analysisRanges;
 
   /// Initialize a newly created instrumentation log by parsing each of the
   /// lines in the [logContent] into a separate entry. The log contents should
@@ -182,30 +180,30 @@
   }
 
   /// Return a list of the completion events associated with the given [id].
-  List<NotificationEntry> completionEventsWithId(String id) =>
+  List<NotificationEntry>? completionEventsWithId(String id) =>
       _completionMap[id];
 
   /// Return the log entries that are contained in the given [group].
-  List<LogEntry> entriesInGroup(EntryGroup group) =>
+  List<LogEntry>? entriesInGroup(EntryGroup group) =>
       entryGroups.putIfAbsent(group, () => group.computeMembers(logEntries));
 
   /// Return the entry that is paired with the given [entry], or `null` if there
   /// is no entry paired with it.
-  LogEntry pairedEntry(LogEntry entry) => _pairedEntries[entry];
+  LogEntry? pairedEntry(LogEntry entry) => _pairedEntries[entry];
 
   /// Return the response that corresponds to the given plugin request.
-  PluginRequestEntry pluginRequestFor(PluginResponseEntry entry) =>
+  PluginRequestEntry? pluginRequestFor(PluginResponseEntry entry) =>
       _pluginRequestMap[entry.id];
 
   /// Return the response that corresponds to the given request.
-  PluginResponseEntry pluginResponseFor(PluginRequestEntry entry) =>
+  PluginResponseEntry? pluginResponseFor(PluginRequestEntry entry) =>
       _pluginResponseMap[entry.id];
 
   /// Return the response that corresponds to the given request.
-  RequestEntry requestFor(ResponseEntry entry) => _requestMap[entry.id];
+  RequestEntry? requestFor(ResponseEntry entry) => _requestMap[entry.id];
 
   /// Return the response that corresponds to the given request.
-  ResponseEntry responseFor(RequestEntry entry) => _responseMap[entry.id];
+  ResponseEntry? responseFor(RequestEntry entry) => _responseMap[entry.id];
 
   /// Return a list containing all of the task entries between the start of
   /// analysis notification at the given [startIndex] and the matching end of
@@ -213,7 +211,7 @@
   /// corresponding end notification.
   List<TaskEntry> taskEntriesFor(int startIndex) {
     var taskEntries = <TaskEntry>[];
-    NotificationEntry startEntry = logEntries[startIndex];
+    var startEntry = logEntries[startIndex] as NotificationEntry;
     var endEntry = pairedEntry(startEntry);
     var lastIndex = endEntry == null ? logEntries.length : endEntry.index;
     for (var i = startEntry.index + 1; i < lastIndex; i++) {
@@ -291,9 +289,9 @@
     }
     logEntries = <LogEntry>[];
     analysisRanges = <EntryRange>[];
-    NotificationEntry analysisStartEntry;
+    NotificationEntry? analysisStartEntry;
     var analysisStartIndex = -1;
-    NotificationEntry pubStartEntry;
+    NotificationEntry? pubStartEntry;
     for (var line in logContent) {
       var entry = LogEntry.from(logEntries.length, line);
       if (entry != null) {
@@ -302,7 +300,7 @@
           _requestMap[entry.id] = entry;
         } else if (entry is ResponseEntry) {
           _responseMap[entry.id] = entry;
-          var request = _requestMap[entry.id];
+          var request = _requestMap[entry.id]!;
           _pairedEntries[entry] = request;
           _pairedEntries[request] = entry;
         } else if (entry is NotificationEntry) {
@@ -350,8 +348,8 @@
               }
             }
           } else if (entry.event == 'completion.results') {
-            String id = entry.param('id');
-            if (id != null) {
+            var id = entry.param('id');
+            if (id is String) {
               _completionMap
                   .putIfAbsent(id, () => <NotificationEntry>[])
                   .add(entry);
@@ -361,7 +359,7 @@
           _pluginRequestMap[entry.id] = entry;
         } else if (entry is PluginResponseEntry) {
           _pluginResponseMap[entry.id] = entry;
-          var request = _pluginRequestMap[entry.id];
+          var request = _pluginRequestMap[entry.id]!;
           _pairedEntries[entry] = request;
           _pairedEntries[request] = entry;
         }
@@ -440,7 +438,7 @@
       buffer.write(object);
     } else if (object is Map) {
       buffer.write('{<br>');
-      object.forEach((Object key, Object value) {
+      object.forEach((key, value) {
         var newIndent = indent + singleIndent;
         buffer.write(newIndent);
         _format(buffer, newIndent, key);
@@ -452,7 +450,7 @@
       buffer.write('}');
     } else if (object is List) {
       buffer.write('[<br>');
-      object.forEach((Object element) {
+      object.forEach((element) {
         var newIndent = indent + singleIndent;
         buffer.write(newIndent);
         _format(buffer, newIndent, element);
@@ -513,13 +511,53 @@
 
   /// A list containing the descriptions of problems that were found while
   /// processing the log file, or `null` if no problems were found.
-  List<String> _problems;
+  List<String>? _problems;
 
   /// Initialize a newly created log entry with the given [timeStamp].
   LogEntry(this.index, this.timeStamp);
 
+  /// Return `true` if any problems were found while processing the log file.
+  bool get hasProblems => _problems != null;
+
+  /// Return the value of the component used to indicate the kind of the entry.
+  /// This is the abbreviation recorded in the entry.
+  String get kind;
+
+  /// Return a human-readable representation of the kind of this entry.
+  String get kindName => kindMap[kind] ?? kind;
+
+  /// Return a list containing the descriptions of problems that were found
+  /// while processing the log file, or `null` if no problems were found.
+  List<String>? get problems => _problems;
+
+  /// Return a date that is equivalent to the [timeStamp].
+  DateTime get toTime => DateTime.fromMillisecondsSinceEpoch(timeStamp);
+
+  /// Return an HTML representation of the details of the entry.
+  String details() {
+    var buffer = StringBuffer();
+    _appendDetails(buffer);
+    return buffer.toString();
+  }
+
+  /// Record that the given [problem] was found while processing the log file.
+  void recordProblem(String problem) {
+    var problems = _problems ??= <String>[];
+    problems.add(problem);
+  }
+
+  /// Append details related to this entry to the given [buffer].
+  void _appendDetails(StringBuffer buffer) {
+    var problems = _problems;
+    if (problems != null) {
+      for (var problem in problems) {
+        buffer.write('<p><span class="error">$problem</span></p>');
+      }
+    }
+  }
+
   /// Create a log entry from the given encoded form of the [entry].
-  factory LogEntry.from(int index, String entry) {
+  static LogEntry? from(int index, String entry) {
     if (entry.isEmpty) {
       return null;
     }
@@ -583,45 +621,6 @@
     }
   }
 
-  /// Return `true` if any problems were found while processing the log file.
-  bool get hasProblems => _problems != null;
-
-  /// Return the value of the component used to indicate the kind of the entry.
-  /// This is the abbreviation recorded in the entry.
-  String get kind;
-
-  /// Return a human-readable representation of the kind of this entry.
-  String get kindName => kindMap[kind] ?? kind;
-
-  /// Return a list containing the descriptions of problems that were found
-  /// while processing the log file, or `null` if no problems were found.
-  List<String> get problems => _problems;
-
-  /// Return a date that is equivalent to the [timeStamp].
-  DateTime get toTime => DateTime.fromMillisecondsSinceEpoch(timeStamp);
-
-  /// Return an HTML representation of the details of the entry.
-  String details() {
-    var buffer = StringBuffer();
-    _appendDetails(buffer);
-    return buffer.toString();
-  }
-
-  /// Record that the given [problem] was found while processing the log file.
-  void recordProblem(String problem) {
-    _problems ??= <String>[];
-    _problems.add(problem);
-  }
-
-  /// Append details related to this entry to the given [buffer].
-  void _appendDetails(StringBuffer buffer) {
-    if (_problems != null) {
-      for (var problem in _problems) {
-        buffer.write('<p><span class="error">$problem</span></p>');
-      }
-    }
-  }
-
   /// Parse the given encoded form of the [entry] into a list of components. The
   /// first component is always the time stamp for when the entry was generated.
   /// The second component is always the kind of the entry. The remaining
@@ -689,7 +688,7 @@
 
   /// Return the value of the parameter with the given [parameterName], or
   /// `null` if there is no such parameter.
-  dynamic param(String parameterName) {
+  Object? param(String parameterName) {
     var parameters = data['params'];
     if (parameters is Map) {
       return parameters[parameterName];
@@ -884,10 +883,10 @@
   final String description;
 
   /// The name of the class implementing the task.
-  String _taskName;
+  String? _taskName;
 
   /// The description of the target of the task.
-  String _target;
+  String? _target;
 
   /// Initialize a newly created entry with the given [index] and [timeStamp] to
   /// represent the execution of an analysis task in the given [context] that is
@@ -903,7 +902,7 @@
     if (_target == null) {
       _splitDescription();
     }
-    return _target;
+    return _target!;
   }
 
   /// Return the name of the class implementing the task.
@@ -911,7 +910,7 @@
     if (_taskName == null) {
       _splitDescription();
     }
-    return _taskName;
+    return _taskName!;
   }
 
   @override
@@ -932,14 +931,15 @@
       _taskName = description.substring(0, index);
     }
     index = description.lastIndexOf(' ');
-    _target = description.substring(index + 1);
+    var target = description.substring(index + 1);
     var slash = context.lastIndexOf('/');
     if (slash < 0) {
       slash = context.lastIndexOf('\\');
     }
     if (slash >= 0) {
       var prefix = context.substring(0, slash);
-      _target = _target.replaceAll(prefix, '...');
+      target = target.replaceAll(prefix, '...');
     }
+    _target = target;
   }
 }
diff --git a/pkg/analysis_server/tool/instrumentation/log_viewer.dart b/pkg/analysis_server/tool/instrumentation/log_viewer.dart
index 722f148..f3e5379d 100644
--- a/pkg/analysis_server/tool/instrumentation/log_viewer.dart
+++ b/pkg/analysis_server/tool/instrumentation/log_viewer.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:io' as io;
 
 import 'package:args/args.dart';
@@ -46,7 +44,7 @@
 
   /// Print usage information.
   void printUsage(ArgParser parser,
-      {String error, Object exception, StackTrace stackTrace}) {
+      {String? error, Object? exception, StackTrace? stackTrace}) {
     if (error != null) {
       print(error);
       print('');
@@ -86,7 +84,7 @@
     }
 
     var arguments = options.rest;
-    if (arguments == null || arguments.length != 1) {
+    if (arguments.length != 1) {
       printUsage(parser, error: 'Missing log file');
       return;
     }
diff --git a/pkg/analysis_server/tool/instrumentation/page/log_page.dart b/pkg/analysis_server/tool/instrumentation/page/log_page.dart
index 67c7ded..6853dc1 100644
--- a/pkg/analysis_server/tool/instrumentation/page/log_page.dart
+++ b/pkg/analysis_server/tool/instrumentation/page/log_page.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:math' as math;
 
 import '../log/log.dart';
@@ -17,21 +15,21 @@
   InstrumentationLog log;
 
   /// The id of the entry groups to be displayed.
-  EntryGroup selectedGroup;
+  late EntryGroup selectedGroup;
 
   /// The entries in the selected group.
-  List<LogEntry> entries;
+  late List<LogEntry> entries;
 
   /// The index of the first entry to be written.
   int pageStart = 0;
 
   /// The number of entries to be written, or `null` if all of the entries
   /// should be written.
-  int pageLength;
+  int? pageLength;
 
   /// The number of digits in the event stamps that are the same for every
   /// entry.
-  int prefixLength;
+  late int prefixLength;
 
   /// A table mapping the ids of plugins to an index for the plugin.
   Map<String, int> pluginIdMap = <String, int>{};
@@ -48,7 +46,7 @@
 
   @override
   void writeBody(StringSink sink) {
-    entries = log.entriesInGroup(selectedGroup);
+    entries = log.entriesInGroup(selectedGroup)!;
     prefixLength = computePrefixLength(entries);
 
     writeMenu(sink);
@@ -102,7 +100,7 @@
 
   /// Return the number of milliseconds elapsed between the [startEntry] and the
   /// [endEntry], or a question .
-  String _getDuration(LogEntry startEntry, LogEntry endEntry) {
+  String _getDuration(LogEntry? startEntry, LogEntry? endEntry) {
     if (startEntry != null && endEntry != null) {
       return (endEntry.timeStamp - startEntry.timeStamp).toString();
     }
@@ -111,7 +109,7 @@
 
   /// Write the given log [entry] to the given [sink].
   void _writeEntry(StringSink sink, LogEntry entry) {
-    String id;
+    String? id;
     var clickHandler = 'clearHighlight()';
     var icon = '';
     var description = entry.kindName;
@@ -226,6 +224,7 @@
   /// Write the entries in the instrumentation log to the given [sink].
   void _writeLeftColumn(StringSink sink) {
     var length = entries.length;
+    var pageLength = this.pageLength;
     var pageEnd =
         pageLength == null ? length : math.min(pageStart + pageLength, length);
     //
@@ -259,7 +258,7 @@
     } else {
       sink.write('<button type="button">');
       sink.write(
-          '<a href="${WebServer.logPath}?group=${selectedGroup.id}&start=${pageStart - pageLength}">');
+          '<a href="${WebServer.logPath}?group=${selectedGroup.id}&start=${pageStart - pageLength!}">');
       sink.write('<b>&lt;</b>');
       sink.writeln('</a></button>');
     }
@@ -269,7 +268,7 @@
     } else {
       sink.write('<button type="button">');
       sink.write(
-          '<a href="${WebServer.logPath}?group=${selectedGroup.id}&start=${pageStart + pageLength}">');
+          '<a href="${WebServer.logPath}?group=${selectedGroup.id}&start=${pageStart + pageLength!}">');
       sink.write('<b>&gt;</b>');
       sink.writeln('</a></button>');
     }
diff --git a/pkg/analysis_server/tool/instrumentation/page/page_writer.dart b/pkg/analysis_server/tool/instrumentation/page/page_writer.dart
index 17658dc..c70e0be 100644
--- a/pkg/analysis_server/tool/instrumentation/page/page_writer.dart
+++ b/pkg/analysis_server/tool/instrumentation/page/page_writer.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:convert';
 
 import '../log/log.dart';
diff --git a/pkg/analysis_server/tool/instrumentation/page/stats_page.dart b/pkg/analysis_server/tool/instrumentation/page/stats_page.dart
index 7ad8f5b..9ef7f85 100644
--- a/pkg/analysis_server/tool/instrumentation/page/stats_page.dart
+++ b/pkg/analysis_server/tool/instrumentation/page/stats_page.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import '../log/log.dart';
 import 'page_writer.dart';
 
@@ -88,8 +86,8 @@
         if (method == 'completion.getSuggestions') {
           var response = log.responseFor(entry);
           if (response != null) {
-            String id = response.result('id');
-            if (id != null) {
+            var id = response.result('id');
+            if (id is String) {
               var events = log.completionEventsWithId(id);
               if (events != null && events.isNotEmpty) {
                 completionResponseTimes
@@ -104,7 +102,7 @@
           pluginErrorCount[entry.pluginId] = count + 1;
         }
       } else if (entry is PluginRequestEntry) {
-        var response = log.pluginResponseFor(entry);
+        var response = log.pluginResponseFor(entry)!;
         var responseTime = response.timeStamp - entry.timeStamp;
         var pluginData = pluginResponseData.putIfAbsent(
             entry.pluginId, () => <String, List<int>>{});
@@ -191,7 +189,7 @@
         '<tr><th>min</th><th>mean</th><th>max</th><th>method</th></tr>');
     var methodNames = latencyData.keys.toList()..sort();
     for (var method in methodNames) {
-      var latencies = latencyData[method]..sort();
+      var latencies = latencyData[method]!..sort();
       // TODO(brianwilkerson) Add a spark-line distribution graph.
       sink.write('<tr><td class="int">');
       sink.write(latencies[0]);
@@ -225,7 +223,7 @@
         sink.writeln('<table>');
         var methodNames = responseData.keys.toList()..sort();
         for (var method in methodNames) {
-          var responseTimes = responseData[method]..sort();
+          var responseTimes = responseData[method]!..sort();
           // TODO(brianwilkerson) Add a spark-line distribution graph.
           sink.write('<tr><td class="int">');
           sink.write(responseTimes[0]);
diff --git a/pkg/analysis_server/tool/instrumentation/server.dart b/pkg/analysis_server/tool/instrumentation/server.dart
index 72757cc..b4a2c4e 100644
--- a/pkg/analysis_server/tool/instrumentation/server.dart
+++ b/pkg/analysis_server/tool/instrumentation/server.dart
@@ -2,8 +2,6 @@
 // for details. All rights reserved. Use of this source code is governed by a
 // BSD-style license that can be found in the LICENSE file.
 
-// @dart = 2.9
-
 import 'dart:collection';
 import 'dart:io';
 
@@ -32,7 +30,7 @@
   final InstrumentationLog log;
 
   /// Future that is completed with the HTTP server once it is running.
-  Future<HttpServer> _server;
+  late Future<HttpServer> _server;
 
   /// Initialize a newly created server.
   WebServer(this.log);
@@ -40,7 +38,7 @@
   Map<String, String> getParameterMap(HttpRequest request) {
     Map<String, String> parameterMap = HashMap<String, String>();
     var query = request.uri.query;
-    if (query != null && query.isNotEmpty) {
+    if (query.isNotEmpty) {
       var pairs = query.split('&');
       for (var pair in pairs) {
         var parts = pair.split('=');
@@ -157,7 +155,7 @@
     var groupId = parameterMap['group'];
     var startIndex = parameterMap['start'];
     var page = LogPage(log);
-    page.selectedGroup = EntryGroup.withId(groupId ?? 'nonTask');
+    page.selectedGroup = EntryGroup.withId(groupId ?? 'nonTask')!;
     if (startIndex != null) {
       page.pageStart = int.parse(startIndex);
     } else {
@@ -169,15 +167,13 @@
 
   /// Write a representation of the given [stackTrace] to the given [sink].
   void _writeStackTrace(StringSink sink, StackTrace stackTrace) {
-    if (stackTrace != null) {
-      var trace = stackTrace.toString().replaceAll('#', '<br>#');
-      if (trace.startsWith('<br>#')) {
-        trace = trace.substring(4);
-      }
-      sink.write('<p>');
-      sink.write(trace);
-      sink.write('</p>');
+    var trace = stackTrace.toString().replaceAll('#', '<br>#');
+    if (trace.startsWith('<br>#')) {
+      trace = trace.substring(4);
     }
+    sink.write('<p>');
+    sink.write(trace);
+    sink.write('</p>');
   }
 
   void _writeStatsPage(HttpRequest request, StringBuffer buffer) {
diff --git a/tools/VERSION b/tools/VERSION
index 6086192..df1501b 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 13
 PATCH 0
-PRERELEASE 201
+PRERELEASE 202
 PRERELEASE_PATCH 0
\ No newline at end of file