Version 2.13.0-198.0.dev

Merge commit '454d4db340022c1478d36f645696714a30bdf3ee' into 'dev'
diff --git a/pkg/analysis_server/lib/protocol/protocol_generated.dart b/pkg/analysis_server/lib/protocol/protocol_generated.dart
index 898ea61..b434a60 100644
--- a/pkg/analysis_server/lib/protocol/protocol_generated.dart
+++ b/pkg/analysis_server/lib/protocol/protocol_generated.dart
@@ -3155,7 +3155,7 @@
 class AnalysisUpdateContentParams implements RequestParams {
   /// A table mapping the files whose content has changed to a description of
   /// the content change.
-  Map<String, dynamic> files;
+  Map<String, Object> files;
 
   AnalysisUpdateContentParams(this.files);
 
@@ -3163,7 +3163,7 @@
       JsonDecoder jsonDecoder, String jsonPath, Object? json) {
     json ??= {};
     if (json is Map) {
-      Map<String, dynamic> files;
+      Map<String, Object> files;
       if (json.containsKey('files')) {
         files = jsonDecoder.decodeMap(jsonPath + '.files', json['files'],
             valueDecoder: (String jsonPath, Object? json) =>
@@ -3194,8 +3194,8 @@
   @override
   Map<String, Object> toJson() {
     var result = <String, Object>{};
-    result['files'] =
-        mapMap(files, valueCallback: (dynamic value) => value.toJson());
+    result['files'] = mapMap(files,
+        valueCallback: (Object value) => (value as dynamic).toJson());
     return result;
   }
 
@@ -3210,7 +3210,7 @@
   @override
   bool operator ==(other) {
     if (other is AnalysisUpdateContentParams) {
-      return mapEqual(files, other.files, (dynamic a, dynamic b) => a == b);
+      return mapEqual(files, other.files, (Object a, Object b) => a == b);
     }
     return false;
   }
diff --git a/pkg/analysis_server/test/client/impl/expect_mixin.dart b/pkg/analysis_server/test/client/impl/expect_mixin.dart
index 7f8444e..7f75f64 100644
--- a/pkg/analysis_server/test/client/impl/expect_mixin.dart
+++ b/pkg/analysis_server/test/client/impl/expect_mixin.dart
@@ -2,15 +2,13 @@
 // 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:matcher/matcher.dart';
 
 typedef _Predicate<T> = bool Function(T value);
 
 /// Lightweight expect that can be run outside of a test context.
 class ExpectMixin {
-  void expect(actual, matcher, {String reason}) {
+  void expect(actual, matcher, {String? reason}) {
     matcher = _wrapMatcher(matcher);
     var matchState = {};
     try {
diff --git a/pkg/analysis_server/test/integration/support/integration_test_methods.dart b/pkg/analysis_server/test/integration/support/integration_test_methods.dart
index 4437c04..c424f42 100644
--- a/pkg/analysis_server/test/integration/support/integration_test_methods.dart
+++ b/pkg/analysis_server/test/integration/support/integration_test_methods.dart
@@ -605,7 +605,7 @@
   ///
   /// Returns
   Future<AnalysisUpdateContentResult> sendAnalysisUpdateContent(
-      Map<String, dynamic> files) async {
+      Map<String, Object> files) async {
     var params = AnalysisUpdateContentParams(files).toJson();
     var result = await server.send('analysis.updateContent', params);
     var decoder = ResponseDecoder(null);
diff --git a/pkg/analysis_server/test/services/linter/linter_test.dart b/pkg/analysis_server/test/services/linter/linter_test.dart
index 031509a..242489b 100644
--- a/pkg/analysis_server/test/services/linter/linter_test.dart
+++ b/pkg/analysis_server/test/services/linter/linter_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/error/error.dart';
 import 'package:analyzer/error/listener.dart';
 import 'package:analyzer/src/analysis_options/analysis_options_provider.dart';
@@ -22,10 +20,12 @@
 @reflectiveTest
 class LinterRuleOptionsValidatorTest {
   final LinterRuleOptionsValidator validator = LinterRuleOptionsValidator();
+
   final AnalysisOptionsProvider optionsProvider = AnalysisOptionsProvider();
 
-  RecordingErrorListener recorder;
-  ErrorReporter reporter;
+  late RecordingErrorListener recorder;
+
+  late ErrorReporter reporter;
 
   List<AnalysisError> get errors => recorder.errors;
 
diff --git a/pkg/analysis_server/test/services/linter/test_all.dart b/pkg/analysis_server/test/services/linter/test_all.dart
index b9d816c..bfc8186 100644
--- a/pkg/analysis_server/test/services/linter/test_all.dart
+++ b/pkg/analysis_server/test/services/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 'linter_test.dart' as linter_test;
diff --git a/pkg/analysis_server/test/src/cider/cider_service.dart b/pkg/analysis_server/test/src/cider/cider_service.dart
index cbbc876..92b637e 100644
--- a/pkg/analysis_server/test/src/cider/cider_service.dart
+++ b/pkg/analysis_server/test/src/cider/cider_service.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 'package:analyzer/src/dart/analysis/byte_store.dart';
@@ -19,10 +17,10 @@
   final ByteStore byteStore = MemoryByteStore();
 
   final StringBuffer logBuffer = StringBuffer();
-  PerformanceLog logger;
-  MockSdk sdk;
+  late PerformanceLog logger;
+  late MockSdk sdk;
 
-  FileResolver fileResolver;
+  late FileResolver fileResolver;
 
   String testPath = '/workspace/dart/test/lib/test.dart';
 
@@ -33,7 +31,7 @@
     var workspace = BazelWorkspace.find(
       resourceProvider,
       convertPath(testPath),
-    );
+    )!;
 
     fileResolver = FileResolver(
       logger,
diff --git a/pkg/analysis_server/test/src/plugin/protocol_test_utilities.dart b/pkg/analysis_server/test/src/plugin/protocol_test_utilities.dart
index a91d352..631dcac 100644
--- a/pkg/analysis_server/test/src/plugin/protocol_test_utilities.dart
+++ b/pkg/analysis_server/test/src/plugin/protocol_test_utilities.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' as server;
 import 'package:analyzer_plugin/protocol/protocol_common.dart';
 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
@@ -66,7 +64,7 @@
 
   /// On return, increment [stringIndex] by 3 (or 4 if no [file] name is
   /// provided) and [intIndex] by 4.
-  AnalysisError analysisError(int stringIndex, int intIndex, {String file}) {
+  AnalysisError analysisError(int stringIndex, int intIndex, {String? file}) {
     return AnalysisError(
         AnalysisErrorSeverity.ERROR,
         AnalysisErrorType.COMPILE_TIME_ERROR,
@@ -78,7 +76,7 @@
   }
 
   /// On return, increment [stringIndex] by 5 and [intIndex] by 5.
-  Element element(int stringIndex, int intIndex, {ElementKind kind}) =>
+  Element element(int stringIndex, int intIndex, {ElementKind? kind}) =>
       Element(kind ?? ElementKind.CLASS, strings[stringIndex++], intIndex++,
           location: Location(fileName(stringIndex++), intIndex++, intIndex++,
               intIndex++, intIndex++, intIndex++, intIndex++),
@@ -95,7 +93,7 @@
       HighlightRegion(HighlightRegionType.FIELD, offset, length);
 
   /// On return, increment [stringIndex] by 1 and [intIndex] by 4.
-  Location location(int stringIndex, int intIndex, {String file}) => Location(
+  Location location(int stringIndex, int intIndex, {String? file}) => Location(
       file ?? fileName(stringIndex),
       intIndex++,
       intIndex++,
@@ -131,7 +129,7 @@
   /// On return, increment [stringIndex] by 2 (or 3 if no [file] name is
   /// provided) and [intIndex] by 4.
   plugin.AnalysisNavigationParams pluginNavigationParams(
-          int stringIndex, int intIndex, {String file}) =>
+          int stringIndex, int intIndex, {String? file}) =>
       plugin.AnalysisNavigationParams(
           file ?? fileName(stringIndex++), <NavigationRegion>[
         NavigationRegion(intIndex++, 2, <int>[0])
@@ -153,7 +151,7 @@
   /// On return, increment [stringIndex] by 2 (or 3 if no [file] name is
   /// provided) and [intIndex] by 4.
   server.AnalysisNavigationParams serverNavigationParams(
-          int stringIndex, int intIndex, {String file}) =>
+          int stringIndex, int intIndex, {String? file}) =>
       server.AnalysisNavigationParams(
           file ?? fileName(stringIndex++), <NavigationRegion>[
         NavigationRegion(intIndex++, 2, <int>[0])
diff --git a/pkg/analysis_server/test/src/services/flutter/constants.dart b/pkg/analysis_server/test/src/services/flutter/constants.dart
index 1f38fd5..3bf64d2 100644
--- a/pkg/analysis_server/test/src/services/flutter/constants.dart
+++ b/pkg/analysis_server/test/src/services/flutter/constants.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
-
 final alignmentEditor = '''
 "editor": {
     "kind": "ENUM_LIKE",
diff --git a/pkg/analysis_server/test/stress/replay/operation.dart b/pkg/analysis_server/test/stress/replay/operation.dart
index 8684ddc..a83d8b8 100644
--- a/pkg/analysis_server/test/stress/replay/operation.dart
+++ b/pkg/analysis_server/test/stress/replay/operation.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
-
 /// Operations to be performed during the simulation.
 import '../utilities/server.dart';
 
diff --git a/pkg/analysis_server/test/stress/replay/replay.dart b/pkg/analysis_server/test/stress/replay/replay.dart
index b4ef02f8..5837c7d 100644
--- a/pkg/analysis_server/test/stress/replay/replay.dart
+++ b/pkg/analysis_server/test/stress/replay/replay.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 stress test for the analysis server.
 import 'dart:io';
 import 'dart:math' as math;
@@ -62,32 +60,32 @@
   static String VERBOSE_FLAG_NAME = 'verbose';
 
   /// The style of interaction to use for analysis.updateContent requests.
-  OverlayStyle overlayStyle;
+  late OverlayStyle overlayStyle;
 
   /// The absolute path of the repository.
-  String repositoryPath;
+  late String repositoryPath;
 
   /// The absolute paths to the analysis roots.
-  List<String> analysisRoots;
+  late List<String> analysisRoots;
 
   /// The git repository.
-  GitRepository repository;
+  late GitRepository repository;
 
   /// The connection to the analysis server.
-  Server server;
+  late Server server;
 
   /// A list of the glob patterns used to identify the files being analyzed by
   /// the server.
-  List<Glob> fileGlobs;
+  late List<Glob> fileGlobs;
 
   /// An object gathering statistics about the simulation.
-  Statistics statistics;
+  late Statistics statistics;
 
   /// A flag indicating whether verbose output should be provided.
   bool verbose = false;
 
   /// The logger to which verbose logging data will be written.
-  Logger logger;
+  late Logger logger;
 
   /// Initialize a newly created driver.
   Driver() {
@@ -219,7 +217,7 @@
   List<int> _getBreakOffsets(String text) {
     var breakOffsets = <int>[];
     var featureSet = FeatureSet.forTesting(sdkVersion: '2.2.2');
-    var scanner = Scanner(null, CharSequenceReader(text),
+    var scanner = Scanner(_TestSource(), CharSequenceReader(text),
         error.AnalysisErrorListener.NULL_LISTENER)
       ..configureFeatures(
         featureSetForOverriding: featureSet,
@@ -236,7 +234,7 @@
       if (token.type == TokenType.IDENTIFIER && length > 3) {
         breakOffsets.add(offset + (length ~/ 2));
       }
-      token = token.next;
+      token = token.next!;
     }
     return breakOffsets;
   }
@@ -315,8 +313,8 @@
       // Iterate over the history, applying changes.
       //
       var firstCheckout = true;
-      ErrorMap expectedErrors;
-      Iterable<String> changedPubspecs;
+      ErrorMap? expectedErrors;
+      late Iterable<String> changedPubspecs;
       while (iterator.moveNext()) {
         //
         // Checkout the commit on which the changes are based.
@@ -416,8 +414,7 @@
   /// Run the simulation by starting up a server and sending it requests.
   Future<void> _runSimulation() async {
     server = Server(logger: logger);
-    var stopwatch = Stopwatch();
-    statistics.stopwatch = stopwatch;
+    var stopwatch = statistics.stopwatch;
     stopwatch.start();
     await server.start();
     server.sendServerSetSubscriptions([ServerService.STATUS]);
@@ -443,7 +440,7 @@
   }
 
   /// Display usage information, preceded by the [errorMessage] if one is given.
-  void _showUsage(ArgParser parser, [String errorMessage]) {
+  void _showUsage(ArgParser parser, [String? errorMessage]) {
     if (errorMessage != null) {
       stderr.writeln(errorMessage);
       stderr.writeln();
@@ -474,25 +471,25 @@
   OverlayStyle overlayStyle;
 
   /// The absolute path of the file to be edited.
-  String filePath;
+  late String filePath;
 
   /// The content of the file before any edits have been applied.
-  String content;
+  late String content;
 
   /// The line info for the file before any edits have been applied.
-  LineInfo lineInfo;
+  late LineInfo lineInfo;
 
   /// The lists of source edits, one list for each hunk being edited.
   List<List<SourceEdit>> editLists = <List<SourceEdit>>[];
 
   /// The current content of the file. This field is only used if the overlay
   /// style is [OverlayStyle.multipleAdd].
-  String currentContent;
+  late String currentContent;
 
   /// Initialize a collection of edits to be associated with the file at the
   /// given [filePath].
   FileEdit(this.overlayStyle, DiffRecord record) {
-    filePath = record.srcPath;
+    filePath = record.srcPath!;
     if (record.isAddition) {
       content = '';
       lineInfo = LineInfo(<int>[0]);
@@ -533,9 +530,7 @@
         } else {
           throw StateError('Failed to handle overlay style = $overlayStyle');
         }
-        if (overlay != null) {
-          addUpdateContent(overlay);
-        }
+        addUpdateContent(overlay);
       }
     }
     addUpdateContent(RemoveContentOverlay());
@@ -553,10 +548,10 @@
   final Driver driver;
 
   /// The stopwatch being used to time the simulation.
-  Stopwatch stopwatch;
+  Stopwatch stopwatch = Stopwatch();
 
   /// The total number of commits in the repository.
-  int commitCount;
+  int commitCount = 0;
 
   /// The number of commits in the repository that touched one of the files in
   /// one of the analysis roots.
@@ -602,3 +597,11 @@
     return '$seconds.$milliseconds';
   }
 }
+
+class _TestSource implements Source {
+  @override
+  String get fullName => '/package/lib/test.dart';
+
+  @override
+  dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
+}
diff --git a/pkg/analysis_server/test/stress/utilities/git.dart b/pkg/analysis_server/test/stress/utilities/git.dart
index 9386e05..05cc2a3 100644
--- a/pkg/analysis_server/test/stress/utilities/git.dart
+++ b/pkg/analysis_server/test/stress/utilities/git.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
-
 /// Support for interacting with a git repository.
 import 'dart:convert';
 import 'dart:io';
@@ -41,9 +39,9 @@
   void _parseLine(String line) {
     var currentHunk = hunks.isEmpty ? null : hunks.last;
     if (line.startsWith('@@')) {
-      var match = hunkHeaderRegExp.matchAsPrefix(line);
-      var srcLine = int.parse(match.group(1));
-      var dstLine = int.parse(match.group(2));
+      var match = hunkHeaderRegExp.matchAsPrefix(line)!;
+      var srcLine = int.parse(match.group(1)!);
+      var dstLine = int.parse(match.group(2)!);
       hunks.add(DiffHunk(srcLine, dstLine));
     } else if (currentHunk != null && line.startsWith('+')) {
       currentHunk.addLines.add(line.substring(1));
@@ -90,7 +88,7 @@
   Iterable<String> filesMatching(String fileName) {
     return diffRecords
         .where((DiffRecord record) => record.isFor(fileName))
-        .map((DiffRecord record) => record.srcPath);
+        .map((DiffRecord record) => record.srcPath!);
   }
 
   /// Remove any diffs for files that are either (a) outside the given
@@ -98,7 +96,7 @@
   /// [globPatterns].
   void filterDiffs(List<String> inclusionPaths, List<Glob> globPatterns) {
     diffRecords.retainWhere((DiffRecord record) {
-      var filePath = record.srcPath ?? record.dstPath;
+      var filePath = (record.srcPath ?? record.dstPath)!;
       for (var inclusionPath in inclusionPaths) {
         if (path.isWithin(inclusionPath, filePath)) {
           for (var glob in globPatterns) {
@@ -177,7 +175,7 @@
     var srcPath = _makeAbsolute(input.substring(startIndex, endIndex));
     startIndex = endIndex + 1;
     // Parse field 14
-    String dstPath;
+    String? dstPath;
     if (status.startsWith('C') || status.startsWith('R')) {
       endIndex = _findEnd(input, startIndex);
       dstPath = _makeAbsolute(input.substring(startIndex, endIndex));
@@ -256,10 +254,10 @@
   final String status;
 
   /// The path of the src.
-  final String srcPath;
+  final String? srcPath;
 
   /// The path of the dst if this was either a copy or a rename operation.
-  final String dstPath;
+  final String? dstPath;
 
   /// Initialize a newly created diff record.
   DiffRecord(this.repository, this.srcBlob, this.dstBlob, this.status,
@@ -288,12 +286,15 @@
   BlobDiff getBlobDiff() => repository.getBlobDiff(srcBlob, dstBlob);
 
   /// Return `true` if this diff applies to a file with the given name.
-  bool isFor(String fileName) =>
-      (srcPath != null && fileName == path.basename(srcPath)) ||
-      (dstPath != null && fileName == path.basename(dstPath));
+  bool isFor(String fileName) {
+    var srcPath = this.srcPath;
+    var dstPath = this.dstPath;
+    return (srcPath != null && fileName == path.basename(srcPath)) ||
+        (dstPath != null && fileName == path.basename(dstPath));
+  }
 
   @override
-  String toString() => srcPath ?? dstPath;
+  String toString() => srcPath ?? dstPath ?? '<unknown>';
 }
 
 /// A representation of a git repository.
@@ -303,7 +304,7 @@
 
   /// The logger to which git commands should be written, or `null` if the
   /// commands should not be written.
-  final Logger logger;
+  final Logger? logger;
 
   /// Initialize a newly created repository to represent the git repository at
   /// the given [path].
@@ -387,7 +388,7 @@
   final LinearCommitHistory history;
 
   /// The index of the current commit in the list of [commitIds].
-  int currentCommit;
+  late int currentCommit;
 
   /// Initialize a newly created iterator to iterate over the commits with the
   /// given [commitIds];
diff --git a/pkg/analysis_server/test/stress/utilities/logger.dart b/pkg/analysis_server/test/stress/utilities/logger.dart
index 5bb6e0e..8e1d937 100644
--- a/pkg/analysis_server/test/stress/utilities/logger.dart
+++ b/pkg/analysis_server/test/stress/utilities/logger.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 utility class used to write logging information during a test.
 class Logger {
   /// The width of the field in which labels are printed.
@@ -23,7 +21,7 @@
   /// The [label] is used to indicate the kind of information being logged,
   /// while the [content] contains the actual information. If a list of
   /// [arguments] is provided, then they will be written after the content.
-  void log(String label, String content, {List<String> arguments}) {
+  void log(String label, String content, {List<String>? arguments}) {
     for (var i = _labelWidth - label.length; i > 0; i--) {
       sink.write(' ');
     }
diff --git a/pkg/analysis_server/test/stress/utilities/server.dart b/pkg/analysis_server/test/stress/utilities/server.dart
index 635fb81..81d3c23 100644
--- a/pkg/analysis_server/test/stress/utilities/server.dart
+++ b/pkg/analysis_server/test/stress/utilities/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
-
 /// Support for interacting with an analysis server that is running in a
 /// separate process.
 import 'dart:async';
@@ -50,36 +48,36 @@
   /// The method that was requested.
   final String method;
 
-  /// The request parameters.
-  final Map<String, dynamic> params;
+  /// The request parameters, or `null` if there are no parameters.
+  final Map<String, dynamic>? params;
 
   /// The time at which the request was sent.
   final int requestTime;
 
   /// The time at which the response was received, or `null` if no response has
   /// been received.
-  int responseTime;
+  int? responseTime;
 
   /// The response that was received.
-  Response _response;
+  Response? _response;
 
   /// The completer that will be completed when a response is received.
-  Completer<Response> _responseCompleter;
+  Completer<Response>? _responseCompleter;
 
   /// Initialize a newly created set of request data.
   RequestData(this.id, this.method, this.params, this.requestTime);
 
   /// Return the number of milliseconds that elapsed between the request and the
   /// response. This getter assumes that the response was received.
-  int get elapsedTime => responseTime - requestTime;
+  int get elapsedTime => responseTime! - requestTime;
 
   /// Return a future that will complete when a response is received.
   Future<Response> get respondedTo {
     if (_response != null) {
       return Future.value(_response);
     }
-    _responseCompleter ??= Completer<Response>();
-    return _responseCompleter.future;
+    var completer = _responseCompleter ??= Completer<Response>();
+    return completer.future;
   }
 
   /// Record that the given [response] was received.
@@ -91,8 +89,9 @@
     }
     responseTime = currentTime;
     _response = response;
-    if (_responseCompleter != null) {
-      _responseCompleter.complete(response);
+    var completer = _responseCompleter;
+    if (completer != null) {
+      completer.complete(response);
       _responseCompleter = null;
     }
   }
@@ -112,11 +111,11 @@
 
   /// The logger to which the communications log should be written, or `null` if
   /// the log should not be written.
-  final Logger logger;
+  final Logger? logger;
 
   /// The process in which the server is running, or `null` if the server hasn't
   /// been started yet.
-  Process _process;
+  Process? _process;
 
   /// Number that should be used to compute the 'id' to send in the next command
   /// sent to the server.
@@ -138,11 +137,11 @@
 
   /// The completer that will be completed the next time a 'server.status'
   /// notification is received from the server with 'analyzing' set to false.
-  Completer<void> _analysisFinishedCompleter;
+  Completer<void>? _analysisFinishedCompleter;
 
   /// The completer that will be completed the next time a 'server.connected'
   /// notification is received from the server.
-  Completer<void> _serverConnectedCompleter;
+  Completer<void>? _serverConnectedCompleter;
 
   /// A table mapping the ids of requests that have been sent to the server to
   /// data about those requests.
@@ -167,8 +166,8 @@
   /// multiple times in one test; each time it is used it will wait afresh for
   /// analysis to finish.
   Future get analysisFinished {
-    _analysisFinishedCompleter ??= Completer<void>();
-    return _analysisFinishedCompleter.future;
+    var completer = _analysisFinishedCompleter ??= Completer<void>();
+    return completer.future;
   }
 
   /// Return a list of the paths of files that are currently being analyzed.
@@ -243,7 +242,7 @@
           .fold(0, (int count, List<RequestData> list) => count + list.length);
       var countWidth = maxCount.toString().length;
       for (var key in keys) {
-        var requests = requestsByMethod[key];
+        var requests = requestsByMethod[key]!;
         var noResponseCount = 0;
         var responseCount = 0;
         var minTime = -1;
@@ -346,7 +345,7 @@
 
   void sendAnalysisSetAnalysisRoots(
       List<String> included, List<String> excluded,
-      {Map<String, String> packageRoots}) {
+      {Map<String, String>? packageRoots}) {
     _analysisRootIncludes = included;
     var params = AnalysisSetAnalysisRootsParams(included, excluded,
             packageRoots: packageRoots)
@@ -399,7 +398,7 @@
 
   RequestData sendEditFormat(
       String file, int selectionOffset, int selectionLength,
-      {int lineLength}) {
+      {int? lineLength}) {
     var params = EditFormatParams(file, selectionOffset, selectionLength,
             lineLength: lineLength)
         .toJson();
@@ -425,7 +424,7 @@
 
   RequestData sendEditGetRefactoring(RefactoringKind kind, String file,
       int offset, int length, bool validateOnly,
-      {RefactoringOptions options}) {
+      {RefactoringOptions? options}) {
     var params = EditGetRefactoringParams(
             kind, file, offset, length, validateOnly,
             options: options)
@@ -453,7 +452,7 @@
     return _send('execution.deleteContext', params);
   }
 
-  RequestData sendExecutionMapUri(String id, {String file, String uri}) {
+  RequestData sendExecutionMapUri(String id, {String? file, String? uri}) {
     var params = ExecutionMapUriParams(id, file: file, uri: uri).toJson();
     return _send('execution.mapUri', params);
   }
@@ -487,7 +486,7 @@
     _send('search.findTopLevelDeclarations', params);
   }
 
-  void sendSearchGetTypeHierarchy(String file, int offset, {bool superOnly}) {
+  void sendSearchGetTypeHierarchy(String file, int offset, {bool? superOnly}) {
     var params =
         SearchGetTypeHierarchyParams(file, offset, superOnly: superOnly)
             .toJson();
@@ -521,10 +520,10 @@
   /// highlight APIs.
   Future<void> start(
       {bool checked = true,
-      int diagnosticPort,
+      int? diagnosticPort,
       bool profileServer = false,
-      String sdkPath,
-      int servicesPort,
+      String? sdkPath,
+      int? servicesPort,
       bool useAnalysisHighlight2 = false}) async {
     if (_process != null) {
       throw Exception('Process already started');
@@ -573,14 +572,15 @@
 //    stdout.writeln('Launching $serverPath');
 //    stdout.writeln('$dartBinary ${arguments.join(' ')}');
     _process = await Process.start(dartBinary, arguments);
-    _process.exitCode.then((int code) {
+    _process!.exitCode.then((int code) {
       if (code != 0) {
         throw StateError('Server terminated with exit code $code');
       }
     });
     _listenToOutput();
-    _serverConnectedCompleter = Completer<void>();
-    return _serverConnectedCompleter.future;
+    var completer = Completer<void>();
+    _serverConnectedCompleter = completer;
+    return completer.future;
   }
 
   /// Find the root directory of the analysis_server package by proceeding
@@ -601,18 +601,17 @@
     switch (notification.event) {
       case 'server.connected':
 //        new ServerConnectedParams.fromNotification(notification);
-        _serverConnectedCompleter.complete(null);
+        _serverConnectedCompleter!.complete(null);
         break;
       case 'server.error':
 //        new ServerErrorParams.fromNotification(notification);
         throw StateError('Server error: ${notification.toJson()}');
-        break;
       case 'server.status':
         if (_analysisFinishedCompleter != null) {
           var params = ServerStatusParams.fromNotification(notification);
           var analysis = params.analysis;
           if (analysis != null && !analysis.isAnalyzing) {
-            _analysisFinishedCompleter.complete(null);
+            _analysisFinishedCompleter!.complete(null);
           }
         }
         break;
@@ -669,7 +668,7 @@
   /// Handle a [response] received from the server.
   void _handleResponse(Response response) {
     var id = response.id.toString();
-    var requestData = _requestDataMap[id];
+    var requestData = _requestDataMap[id]!;
     requestData.recordResponse(response);
 //    switch (requestData.method) {
 //      case "analysis.getErrors":
@@ -754,8 +753,8 @@
   void _handleStdOut(String line) {
     /// Cast the given [value] to a Map, or throw an [ArgumentError] if the
     /// value cannot be cast.
-    Map asMap(Object value) {
-      if (value is Map) {
+    Map<String, Object?> asMap(Object value) {
+      if (value is Map<String, Object?>) {
         return value;
       }
       throw ArgumentError('Expected a Map, found a ${value.runtimeType}');
@@ -770,7 +769,7 @@
     var message = asMap(json.decoder.convert(trimmedLine));
     if (message.containsKey('id')) {
       // The message is a response.
-      var response = Response.fromJson(message);
+      var response = Response.fromJson(message)!;
       _handleResponse(response);
     } else {
       // The message is a notification.
@@ -793,12 +792,12 @@
           .listen(handler);
     }
 
-    installHandler(_process.stdout, _handleStdOut);
-    installHandler(_process.stderr, _handleStdErr);
+    installHandler(_process!.stdout, _handleStdOut);
+    installHandler(_process!.stderr, _handleStdErr);
   }
 
   /// Send a command to the server. An 'id' will be automatically assigned.
-  RequestData _send(String method, Map<String, dynamic> params) {
+  RequestData _send(String method, Map<String, dynamic>? params) {
     var id = '${_nextId++}';
     var requestData = RequestData(id, method, params, currentTime);
     _requestDataMap[id] = requestData;
@@ -807,7 +806,7 @@
       command['params'] = params;
     }
     var line = json.encode(command);
-    _process.stdin.add(utf8.encoder.convert('$line\n'));
+    _process!.stdin.add(utf8.encoder.convert('$line\n'));
     logger?.log(fromClient, '$line');
     return requestData;
   }
diff --git a/pkg/analysis_server/test/timing/completion/completion_simple.dart b/pkg/analysis_server/test/timing/completion/completion_simple.dart
index c2ec8fd..3984325 100644
--- a/pkg/analysis_server/test/timing/completion/completion_simple.dart
+++ b/pkg/analysis_server/test/timing/completion/completion_simple.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';
 
@@ -31,17 +29,17 @@
 /// minor change inside a method body.
 class SimpleTest extends TimingTest {
   /// The path to the file in which code completion is to be performed.
-  String mainFilePath;
+  late String mainFilePath;
 
   /// The original content of the file.
-  String originalContent;
+  late String originalContent;
 
   /// The offset of the cursor when requesting code completion.
-  int cursorOffset;
+  late int cursorOffset;
 
   /// A completer that will be completed when code completion results have been
   /// received from the server.
-  Completer completionReceived;
+  late Completer completionReceived;
 
   /// Initialize a newly created test.
   SimpleTest();
diff --git a/pkg/analysis_server/test/timing/timing_framework.dart b/pkg/analysis_server/test/timing/timing_framework.dart
index 712257c..b9eb6d0 100644
--- a/pkg/analysis_server/test/timing/timing_framework.dart
+++ b/pkg/analysis_server/test/timing/timing_framework.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';
 import 'dart:math';
@@ -117,10 +115,10 @@
 
   /// The connection to the analysis server.
   @override
-  Server server;
+  late Server server;
 
   /// The temporary directory in which source files can be stored.
-  Directory sourceDirectory;
+  late Directory sourceDirectory;
 
   /// A flag indicating whether the teardown process should skip sending a
   /// "server.shutdown" request because the server is known to have already
@@ -214,7 +212,7 @@
 
   /// Repeatedly execute this test [count] times, adding timing information to
   /// the given list of [times] if it is non-`null`.
-  Future _repeat(int count, List<int> times) {
+  Future _repeat(int count, List<int>? times) {
     var stopwatch = Stopwatch();
     return setUp().then((_) {
       stopwatch.start();
diff --git a/pkg/analysis_server/test/utils/test_instrumentation_service.dart b/pkg/analysis_server/test/utils/test_instrumentation_service.dart
index 5e8ed3e..bd43ac2 100644
--- a/pkg/analysis_server/test/utils/test_instrumentation_service.dart
+++ b/pkg/analysis_server/test/utils/test_instrumentation_service.dart
@@ -2,20 +2,17 @@
 // 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/exception/exception.dart';
 import 'package:analyzer/instrumentation/service.dart';
 
 /// Implementation of [InstrumentationService] that throws on [logException].
 class TestInstrumentationService implements InstrumentationService {
   @override
   void logException(
-    exception, [
-    StackTrace stackTrace,
-    List<InstrumentationServiceAttachment> attachments = const [],
+    Object exception, [
+    StackTrace? stackTrace,
+    List<InstrumentationServiceAttachment>? attachments,
   ]) {
-    throw CaughtException(exception, stackTrace);
+    throw StateError('$exception\n\n$stackTrace');
   }
 
   @override
diff --git a/pkg/analysis_server/test/utils/test_support.dart b/pkg/analysis_server/test/utils/test_support.dart
index eafda82..c3f4888 100644
--- a/pkg/analysis_server/test/utils/test_support.dart
+++ b/pkg/analysis_server/test/utils/test_support.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
-
 /// These classes were copied from `analyzer`. They should be moved into the
 /// `analyzer/lib/src/test_utilities` directory so that they can be shared.
 /// (This version has been converted to a more modern style.)
@@ -25,7 +23,7 @@
   final int length;
 
   /// The message text for the error.
-  final String text;
+  final String? text;
 
   ExpectedContextMessage(this.filePath, this.offset, this.length, {this.text});
 
@@ -53,12 +51,13 @@
   /// The offset of the beginning of the error's region.
   final int length;
 
-  /// The message text of the error or `null` if the message should not be checked.
-  final String message;
+  /// The message text of the error or `null` if the message should not be
+  /// checked.
+  final String? message;
 
-  /// A pattern that should be contained in the error message or `null` if the message
-  /// contents should not be checked.
-  final Pattern messageContains;
+  /// A pattern that should be contained in the error message or `null` if the
+  /// message contents should not be checked.
+  final Pattern? messageContains;
 
   /// The list of context messages that are expected to be associated with the
   /// error.
@@ -81,8 +80,9 @@
     if (message != null && error.message != message) {
       return false;
     }
+    var messageContains = this.messageContains;
     if (messageContains != null &&
-        error.message?.contains(messageContains) != true) {
+        error.message.contains(messageContains) != true) {
       return false;
     }
     var contextMessages = error.contextMessages.toList();
@@ -359,7 +359,7 @@
 
   /// Return the line information associated with the given [source], or `null`
   /// if no line information has been associated with the source.
-  LineInfo getLineInfo(Source source) => _lineInfoMap[source];
+  LineInfo? getLineInfo(Source source) => _lineInfoMap[source];
 
   /// Return `true` if an error with the given [errorCode] has been gathered.
   bool hasError(ErrorCode errorCode) {
diff --git a/pkg/analysis_server/tool/spec/codegen_dart.dart b/pkg/analysis_server/tool/spec/codegen_dart.dart
index af20098..b38ba00 100644
--- a/pkg/analysis_server/tool/spec/codegen_dart.dart
+++ b/pkg/analysis_server/tool/spec/codegen_dart.dart
@@ -37,7 +37,7 @@
     } else if (type is TypeMap) {
       return 'Map<${dartType(type.keyType)}, ${dartType(type.valueType)}>';
     } else if (type is TypeUnion) {
-      return 'dynamic';
+      return 'Object';
     } else {
       throw Exception("Can't convert to a dart type");
     }
diff --git a/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart b/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
index 97af9b0..7410305 100644
--- a/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
+++ b/pkg/analysis_server/tool/spec/codegen_dart_protocol.dart
@@ -677,7 +677,7 @@
               'Returns the [RefactoringProblemSeverity] with the maximal severity.')
         ]);
         writeln(
-            'static RefactoringProblemSeverity max(RefactoringProblemSeverity a, RefactoringProblemSeverity b) =>');
+            'static RefactoringProblemSeverity? max(RefactoringProblemSeverity? a, RefactoringProblemSeverity? b) =>');
         writeln('    maxRefactoringProblemSeverity(a, b);');
         return true;
       default:
@@ -748,7 +748,7 @@
         docComment([
           dom.Text('Returns the [FileEdit] for the given [file], maybe `null`.')
         ]);
-        writeln('SourceFileEdit getFileEdit(String file) =>');
+        writeln('SourceFileEdit? getFileEdit(String file) =>');
         writeln('    getChangeFileEdit(this, file);');
         return true;
       case 'SourceEdit':
@@ -985,7 +985,7 @@
                 'Each choice in the union needs a constant value for the field ${type.field}');
           }
           var closure = fromJsonCode(choice).asClosure;
-          decoders.add('${literalString(field.value)}: $closure');
+          decoders.add('${literalString(field.value as String)}: $closure');
         } else {
           throw Exception('Union types must be unions of objects.');
         }
@@ -1074,7 +1074,10 @@
           throw Exception('Union types must be unions of objects');
         }
       }
-      return ToJsonSnippet(dartType(type), (String value) => '$value.toJson()');
+      return ToJsonSnippet(
+        dartType(type),
+        (String value) => '($value as dynamic).toJson()',
+      );
     } else if (resolvedType is TypeObject || resolvedType is TypeEnum) {
       return ToJsonSnippet(dartType(type), (String value) => '$value.toJson()');
     } else {
diff --git a/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart b/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
index 68e4a9b..5a777f6 100644
--- a/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
+++ b/pkg/analysis_server_client/lib/src/protocol/protocol_generated.dart
@@ -3155,7 +3155,7 @@
 class AnalysisUpdateContentParams implements RequestParams {
   /// A table mapping the files whose content has changed to a description of
   /// the content change.
-  Map<String, dynamic> files;
+  Map<String, Object> files;
 
   AnalysisUpdateContentParams(this.files);
 
@@ -3163,7 +3163,7 @@
       JsonDecoder jsonDecoder, String jsonPath, Object? json) {
     json ??= {};
     if (json is Map) {
-      Map<String, dynamic> files;
+      Map<String, Object> files;
       if (json.containsKey('files')) {
         files = jsonDecoder.decodeMap(jsonPath + '.files', json['files'],
             valueDecoder: (String jsonPath, Object? json) =>
@@ -3194,8 +3194,8 @@
   @override
   Map<String, Object> toJson() {
     var result = <String, Object>{};
-    result['files'] =
-        mapMap(files, valueCallback: (dynamic value) => value.toJson());
+    result['files'] = mapMap(files,
+        valueCallback: (Object value) => (value as dynamic).toJson());
     return result;
   }
 
@@ -3210,7 +3210,7 @@
   @override
   bool operator ==(other) {
     if (other is AnalysisUpdateContentParams) {
-      return mapEqual(files, other.files, (dynamic a, dynamic b) => a == b);
+      return mapEqual(files, other.files, (Object a, Object b) => a == b);
     }
     return false;
   }
diff --git a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
index cb24558..219aadc 100644
--- a/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
+++ b/pkg/analyzer/lib/src/dart/micro/resolve_file.dart
@@ -94,7 +94,7 @@
     @deprecated ByteStore byteStore,
     SourceFactory sourceFactory,
     String Function(String path) getFileDigest,
-    void Function(List<String> paths) prefetchFiles, {
+    void Function(List<String> paths)? prefetchFiles, {
     required Workspace workspace,
     @deprecated Duration? libraryContextResetTimeout,
   }) : this.from(
diff --git a/pkg/analyzer_plugin/lib/protocol/protocol_generated.dart b/pkg/analyzer_plugin/lib/protocol/protocol_generated.dart
index 95f4362..937d5c2 100644
--- a/pkg/analyzer_plugin/lib/protocol/protocol_generated.dart
+++ b/pkg/analyzer_plugin/lib/protocol/protocol_generated.dart
@@ -1307,7 +1307,7 @@
       if (json.containsKey('files')) {
         files = jsonDecoder.decodeMap(jsonPath + '.files', json['files'],
             valueDecoder: (String jsonPath, Object? json) =>
-                jsonDecoder.decodeUnion(jsonPath, json as Map, 'type', {
+                jsonDecoder.decodeUnion(jsonPath, json, 'type', {
                   'add': (String jsonPath, Object? json) =>
                       AddContentOverlay.fromJson(jsonDecoder, jsonPath, json),
                   'change': (String jsonPath, Object? json) =>
diff --git a/pkg/analyzer_plugin/tool/spec/codegen_dart_protocol.dart b/pkg/analyzer_plugin/tool/spec/codegen_dart_protocol.dart
index c47eb2d..85fb45a 100644
--- a/pkg/analyzer_plugin/tool/spec/codegen_dart_protocol.dart
+++ b/pkg/analyzer_plugin/tool/spec/codegen_dart_protocol.dart
@@ -961,7 +961,7 @@
         }
       }
       return FromJsonSnippet((String jsonPath, String json) =>
-          'jsonDecoder.decodeUnion($jsonPath, $json as Map, ${literalString(type.field)}, {${decoders.join(', ')}})');
+          'jsonDecoder.decodeUnion($jsonPath, $json, ${literalString(type.field)}, {${decoders.join(', ')}})');
     } else {
       throw Exception("Can't convert $type from JSON");
     }
diff --git a/tools/VERSION b/tools/VERSION
index 275cd60..77ebaab 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
 MAJOR 2
 MINOR 13
 PATCH 0
-PRERELEASE 197
+PRERELEASE 198
 PRERELEASE_PATCH 0
\ No newline at end of file