Sound null safety for framework and flutter_test (#68642)

diff --git a/dev/bots/test.dart b/dev/bots/test.dart
index 9b6bb83..b21dec1 100644
--- a/dev/bots/test.dart
+++ b/dev/bots/test.dart
@@ -528,7 +528,8 @@
 
 Future<void> _runFrameworkTests() async {
   final bq.BigqueryApi bigqueryApi = await _getBigqueryApi();
-  final List<String> nullSafetyOptions = <String>['--null-assertions', '--no-sound-null-safety'];
+  final List<String> soundNullSafetyOptions     = <String>['--enable-experiment=non-nullable', '--null-assertions', '--sound-null-safety'];
+  final List<String> mixedModeNullSafetyOptions = <String>['--enable-experiment=non-nullable', '--null-assertions', '--no-sound-null-safety'];
   final List<String> trackWidgetCreationAlternatives = <String>['--track-widget-creation', '--no-track-widget-creation'];
 
   Future<void> runWidgets() async {
@@ -536,7 +537,7 @@
     for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) {
       await _runFlutterTest(
         path.join(flutterRoot, 'packages', 'flutter'),
-        options: <String>[trackWidgetCreationOption, ...nullSafetyOptions],
+        options: <String>[trackWidgetCreationOption, ...soundNullSafetyOptions],
         tableData: bigqueryApi?.tabledata,
         tests: <String>[ path.join('test', 'widgets') + path.separator ],
       );
@@ -562,7 +563,7 @@
     for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) {
       await _runFlutterTest(
         path.join(flutterRoot, 'packages', 'flutter'),
-        options: <String>[trackWidgetCreationOption, ...nullSafetyOptions],
+        options: <String>[trackWidgetCreationOption, ...soundNullSafetyOptions],
         tableData: bigqueryApi?.tabledata,
         tests: tests,
       );
@@ -613,14 +614,14 @@
     await _runFlutterTest(path.join(flutterRoot, 'dev', 'manual_tests'), tableData: bigqueryApi?.tabledata);
     await _runFlutterTest(path.join(flutterRoot, 'dev', 'tools', 'vitool'), tableData: bigqueryApi?.tabledata);
     await _runFlutterTest(path.join(flutterRoot, 'examples', 'hello_world'), tableData: bigqueryApi?.tabledata);
-    await _runFlutterTest(path.join(flutterRoot, 'examples', 'layers'), tableData: bigqueryApi?.tabledata);
+    await _runFlutterTest(path.join(flutterRoot, 'examples', 'layers'), tableData: bigqueryApi?.tabledata, options: mixedModeNullSafetyOptions);
     await _runFlutterTest(path.join(flutterRoot, 'dev', 'benchmarks', 'test_apps', 'stocks'), tableData: bigqueryApi?.tabledata);
     await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_driver'), tableData: bigqueryApi?.tabledata, tests: <String>[path.join('test', 'src', 'real_tests')]);
     await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_goldens'), tableData: bigqueryApi?.tabledata);
     await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_localizations'), tableData: bigqueryApi?.tabledata);
-    await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_test'), tableData: bigqueryApi?.tabledata, options: nullSafetyOptions);
+    await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_test'), tableData: bigqueryApi?.tabledata, options: soundNullSafetyOptions);
     await _runFlutterTest(path.join(flutterRoot, 'packages', 'fuchsia_remote_debug_protocol'), tableData: bigqueryApi?.tabledata);
-    await _runFlutterTest(path.join(flutterRoot, 'dev', 'integration_tests', 'non_nullable'), options: nullSafetyOptions);
+    await _runFlutterTest(path.join(flutterRoot, 'dev', 'integration_tests', 'non_nullable'), options: mixedModeNullSafetyOptions);
     await _runFlutterTest(
       path.join(flutterRoot, 'dev', 'tracing_tests'),
       options: <String>['--enable-vmservice'],
diff --git a/examples/layers/analysis_options.yaml b/examples/layers/analysis_options.yaml
new file mode 100644
index 0000000..03733cd
--- /dev/null
+++ b/examples/layers/analysis_options.yaml
@@ -0,0 +1,13 @@
+# Use the parent analysis options settings and enable null-experiment.
+
+include: ../../analysis_options.yaml
+
+analyzer:
+  enable-experiment:
+    - non-nullable
+  errors:
+    always_require_non_null_named_parameters: false # not needed with nnbd
+    type_init_formals: false # https://github.com/dart-lang/linter/issues/2192
+    unrelated_type_equality_checks: false # https://github.com/dart-lang/linter/issues/2196
+    void_checks: false # https://github.com/dart-lang/linter/issues/2185
+    unnecessary_null_comparison: false # Turned off until null-safe rollout is complete.
diff --git a/examples/layers/rendering/custom_coordinate_systems.dart b/examples/layers/rendering/custom_coordinate_systems.dart
index 5307b56..0402b77 100644
--- a/examples/layers/rendering/custom_coordinate_systems.dart
+++ b/examples/layers/rendering/custom_coordinate_systems.dart
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// @dart = 2.8
+// @dart = 2.10
 
 // This example shows how to build a render tree with a non-cartesian coordinate
 // system. Most of the guts of this examples are in src/sector_layout.dart.
diff --git a/examples/layers/rendering/src/sector_layout.dart b/examples/layers/rendering/src/sector_layout.dart
index 6cb2d3c..dbef998 100644
--- a/examples/layers/rendering/src/sector_layout.dart
+++ b/examples/layers/rendering/src/sector_layout.dart
@@ -2,13 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-// @dart = 2.8
+// @dart = 2.10
 
 import 'dart:math' as math;
 
 import 'package:flutter/rendering.dart';
 import 'package:flutter/gestures.dart';
-import 'package:meta/meta.dart';
 
 const double kTwoPi = 2 * math.pi;
 
@@ -33,11 +32,11 @@
   final double maxDeltaTheta;
 
   double constrainDeltaRadius(double deltaRadius) {
-    return deltaRadius.clamp(minDeltaRadius, maxDeltaRadius) as double;
+    return deltaRadius.clamp(minDeltaRadius, maxDeltaRadius);
   }
 
   double constrainDeltaTheta(double deltaTheta) {
-    return deltaTheta.clamp(minDeltaTheta, maxDeltaTheta) as double;
+    return deltaTheta.clamp(minDeltaTheta, maxDeltaTheta);
   }
 
   @override
@@ -49,7 +48,7 @@
   @override
   bool debugAssertIsValid({
     bool isAppliedConstraint = false,
-    InformationCollector informationCollector,
+    InformationCollector? informationCollector,
   }) {
     assert(isNormalized);
     return isNormalized;
@@ -102,7 +101,7 @@
   // RenderSectors always use SectorParentData subclasses, as they need to be
   // able to read their position information for painting and hit testing.
   @override
-  SectorParentData get parentData => super.parentData as SectorParentData;
+  SectorParentData? get parentData => super.parentData as SectorParentData?;
 
   SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
     return SectorDimensions.withConstraints(constraints);
@@ -145,27 +144,27 @@
   @override
   Rect get semanticBounds => Rect.fromLTWH(-deltaRadius, -deltaRadius, 2.0 * deltaRadius, 2.0 * deltaRadius);
 
-  bool hitTest(SectorHitTestResult result, { double radius, double theta }) {
-    if (radius < parentData.radius || radius >= parentData.radius + deltaRadius ||
-        theta < parentData.theta || theta >= parentData.theta + deltaTheta)
+  bool hitTest(SectorHitTestResult result, { required double radius, required double theta }) {
+    if (radius < parentData!.radius || radius >= parentData!.radius + deltaRadius ||
+        theta < parentData!.theta || theta >= parentData!.theta + deltaTheta)
       return false;
     hitTestChildren(result, radius: radius, theta: theta);
     result.add(SectorHitTestEntry(this, radius: radius, theta: theta));
     return true;
   }
-  void hitTestChildren(SectorHitTestResult result, { double radius, double theta }) { }
+  void hitTestChildren(SectorHitTestResult result, { required double radius, required double theta }) { }
 
-  double deltaRadius;
-  double deltaTheta;
+  late double deltaRadius;
+  late double deltaTheta;
 }
 
 abstract class RenderDecoratedSector extends RenderSector {
 
-  RenderDecoratedSector(BoxDecoration decoration) : _decoration = decoration;
+  RenderDecoratedSector(BoxDecoration? decoration) : _decoration = decoration;
 
-  BoxDecoration _decoration;
-  BoxDecoration get decoration => _decoration;
-  set decoration(BoxDecoration value) {
+  BoxDecoration? _decoration;
+  BoxDecoration? get decoration => _decoration;
+  set decoration(BoxDecoration? value) {
     if (value == _decoration)
       return;
     _decoration = value;
@@ -182,16 +181,16 @@
     if (_decoration == null)
       return;
 
-    if (_decoration.color != null) {
+    if (_decoration!.color != null) {
       final Canvas canvas = context.canvas;
-      final Paint paint = Paint()..color = _decoration.color;
+      final Paint paint = Paint()..color = _decoration!.color!;
       final Path path = Path();
-      final double outerRadius = parentData.radius + deltaRadius;
+      final double outerRadius = parentData!.radius + deltaRadius;
       final Rect outerBounds = Rect.fromLTRB(offset.dx-outerRadius, offset.dy-outerRadius, offset.dx+outerRadius, offset.dy+outerRadius);
-      path.arcTo(outerBounds, parentData.theta, deltaTheta, true);
-      final double innerRadius = parentData.radius;
+      path.arcTo(outerBounds, parentData!.theta, deltaTheta, true);
+      final double innerRadius = parentData!.radius;
       final Rect innerBounds = Rect.fromLTRB(offset.dx-innerRadius, offset.dy-innerRadius, offset.dx+innerRadius, offset.dy+innerRadius);
-      path.arcTo(innerBounds, parentData.theta + deltaTheta, -deltaTheta, false);
+      path.arcTo(innerBounds, parentData!.theta + deltaTheta, -deltaTheta, false);
       path.close();
       canvas.drawPath(path, paint);
     }
@@ -202,25 +201,25 @@
 class SectorChildListParentData extends SectorParentData with ContainerParentDataMixin<RenderSector> { }
 
 class RenderSectorWithChildren extends RenderDecoratedSector with ContainerRenderObjectMixin<RenderSector, SectorChildListParentData> {
-  RenderSectorWithChildren(BoxDecoration decoration) : super(decoration);
+  RenderSectorWithChildren(BoxDecoration? decoration) : super(decoration);
 
   @override
-  void hitTestChildren(SectorHitTestResult result, { double radius, double theta }) {
-    RenderSector child = lastChild;
+  void hitTestChildren(SectorHitTestResult result, { required double radius, required double theta }) {
+    RenderSector? child = lastChild;
     while (child != null) {
       if (child.hitTest(result, radius: radius, theta: theta))
         return;
-      final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
+      final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
       child = childParentData.previousSibling;
     }
   }
 
   @override
   void visitChildren(RenderObjectVisitor visitor) {
-    RenderSector child = lastChild;
+    RenderSector? child = lastChild;
     while (child != null) {
       visitor(child);
-      final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
+      final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
       child = childParentData.previousSibling;
     }
   }
@@ -230,7 +229,7 @@
   // lays out RenderSector children in a ring
 
   RenderSectorRing({
-    BoxDecoration decoration,
+    BoxDecoration? decoration,
     double deltaRadius = double.infinity,
     double padding = 0.0,
   }) : _padding = padding,
@@ -275,7 +274,7 @@
     final double paddingTheta = math.atan(padding / (radius + outerDeltaRadius));
     double innerTheta = paddingTheta; // increments with each child
     double remainingDeltaTheta = math.max(0.0, constraints.maxDeltaTheta - (innerTheta + paddingTheta));
-    RenderSector child = firstChild;
+    RenderSector? child = firstChild;
     while (child != null) {
       final SectorConstraints innerConstraints = SectorConstraints(
         maxDeltaRadius: innerDeltaRadius,
@@ -284,7 +283,7 @@
       final SectorDimensions childDimensions = child.getIntrinsicDimensions(innerConstraints, childRadius);
       innerTheta += childDimensions.deltaTheta;
       remainingDeltaTheta -= childDimensions.deltaTheta;
-      final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
+      final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
       child = childParentData.nextSibling;
       if (child != null) {
         innerTheta += paddingTheta;
@@ -302,23 +301,23 @@
     deltaRadius = constraints.constrainDeltaRadius(desiredDeltaRadius);
     assert(deltaRadius < double.infinity);
     final double innerDeltaRadius = deltaRadius - padding * 2.0;
-    final double childRadius = parentData.radius + padding;
-    final double paddingTheta = math.atan(padding / (parentData.radius + deltaRadius));
+    final double childRadius = parentData!.radius + padding;
+    final double paddingTheta = math.atan(padding / (parentData!.radius + deltaRadius));
     double innerTheta = paddingTheta; // increments with each child
     double remainingDeltaTheta = constraints.maxDeltaTheta - (innerTheta + paddingTheta);
-    RenderSector child = firstChild;
+    RenderSector? child = firstChild;
     while (child != null) {
       final SectorConstraints innerConstraints = SectorConstraints(
         maxDeltaRadius: innerDeltaRadius,
         maxDeltaTheta: remainingDeltaTheta,
       );
       assert(child.parentData is SectorParentData);
-      child.parentData.theta = innerTheta;
-      child.parentData.radius = childRadius;
+      child.parentData!.theta = innerTheta;
+      child.parentData!.radius = childRadius;
       child.layout(innerConstraints, parentUsesSize: true);
       innerTheta += child.deltaTheta;
       remainingDeltaTheta -= child.deltaTheta;
-      final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
+      final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
       child = childParentData.nextSibling;
       if (child != null) {
         innerTheta += paddingTheta;
@@ -334,10 +333,10 @@
   void paint(PaintingContext context, Offset offset) {
     // TODO(ianh): avoid code duplication
     super.paint(context, offset);
-    RenderSector child = firstChild;
+    RenderSector? child = firstChild;
     while (child != null) {
       context.paintChild(child, offset);
-      final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
+      final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
       child = childParentData.nextSibling;
     }
   }
@@ -348,7 +347,7 @@
   // lays out RenderSector children in a stack
 
   RenderSectorSlice({
-    BoxDecoration decoration,
+    BoxDecoration? decoration,
     double deltaTheta = kTwoPi,
     double padding = 0.0,
   }) : _padding = padding, _desiredDeltaTheta = deltaTheta, super(decoration);
@@ -384,12 +383,12 @@
   @override
   SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
     assert(parentData is SectorParentData);
-    final double paddingTheta = math.atan(padding / parentData.radius);
+    final double paddingTheta = math.atan(padding / parentData!.radius);
     final double outerDeltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta);
     final double innerDeltaTheta = outerDeltaTheta - paddingTheta * 2.0;
-    double childRadius = parentData.radius + padding;
+    double childRadius = parentData!.radius + padding;
     double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0);
-    RenderSector child = firstChild;
+    RenderSector? child = firstChild;
     while (child != null) {
       final SectorConstraints innerConstraints = SectorConstraints(
         maxDeltaRadius: remainingDeltaRadius,
@@ -398,13 +397,13 @@
       final SectorDimensions childDimensions = child.getIntrinsicDimensions(innerConstraints, childRadius);
       childRadius += childDimensions.deltaRadius;
       remainingDeltaRadius -= childDimensions.deltaRadius;
-      final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
+      final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
       child = childParentData.nextSibling;
       childRadius += padding;
       remainingDeltaRadius -= padding;
     }
     return SectorDimensions.withConstraints(constraints,
-                                                deltaRadius: childRadius - parentData.radius,
+                                                deltaRadius: childRadius - parentData!.radius,
                                                 deltaTheta: outerDeltaTheta);
   }
 
@@ -413,28 +412,28 @@
     assert(parentData is SectorParentData);
     deltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta);
     assert(deltaTheta <= kTwoPi);
-    final double paddingTheta = math.atan(padding / parentData.radius);
-    final double innerTheta = parentData.theta + paddingTheta;
+    final double paddingTheta = math.atan(padding / parentData!.radius);
+    final double innerTheta = parentData!.theta + paddingTheta;
     final double innerDeltaTheta = deltaTheta - paddingTheta * 2.0;
-    double childRadius = parentData.radius + padding;
+    double childRadius = parentData!.radius + padding;
     double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0);
-    RenderSector child = firstChild;
+    RenderSector? child = firstChild;
     while (child != null) {
       final SectorConstraints innerConstraints = SectorConstraints(
         maxDeltaRadius: remainingDeltaRadius,
         maxDeltaTheta: innerDeltaTheta,
       );
-      child.parentData.theta = innerTheta;
-      child.parentData.radius = childRadius;
+      child.parentData!.theta = innerTheta;
+      child.parentData!.radius = childRadius;
       child.layout(innerConstraints, parentUsesSize: true);
       childRadius += child.deltaRadius;
       remainingDeltaRadius -= child.deltaRadius;
-      final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
+      final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
       child = childParentData.nextSibling;
       childRadius += padding;
       remainingDeltaRadius -= padding;
     }
-    deltaRadius = childRadius - parentData.radius;
+    deltaRadius = childRadius - parentData!.radius;
   }
 
   // offset must point to the center of our circle
@@ -443,11 +442,11 @@
   void paint(PaintingContext context, Offset offset) {
     // TODO(ianh): avoid code duplication
     super.paint(context, offset);
-    RenderSector child = firstChild;
+    RenderSector? child = firstChild;
     while (child != null) {
       assert(child.parentData is SectorChildListParentData);
       context.paintChild(child, offset);
-      final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
+      final SectorChildListParentData childParentData = child.parentData! as SectorChildListParentData;
       child = childParentData.nextSibling;
     }
   }
@@ -456,7 +455,7 @@
 
 class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChildMixin<RenderSector> {
 
-  RenderBoxToRenderSectorAdapter({ double innerRadius = 0.0, RenderSector child })
+  RenderBoxToRenderSectorAdapter({ double innerRadius = 0.0, RenderSector? child })
     : _innerRadius = innerRadius {
     this.child = child;
   }
@@ -507,13 +506,13 @@
     double height = double.infinity,
   }) {
     assert(child is RenderSector);
-    assert(child.parentData is SectorParentData);
+    assert(child!.parentData is SectorParentData);
     assert(width != null);
     assert(height != null);
     if (!width.isFinite && !height.isFinite)
       return Size.zero;
     final double maxChildDeltaRadius = math.max(0.0, math.min(width, height) / 2.0 - innerRadius);
-    final SectorDimensions childDimensions = child.getIntrinsicDimensions(SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), innerRadius);
+    final SectorDimensions childDimensions = child!.getIntrinsicDimensions(SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), innerRadius);
     final double dimension = (innerRadius + childDimensions.deltaRadius) * 2.0;
     return Size.square(dimension);
   }
@@ -526,12 +525,12 @@
       return;
     }
     assert(child is RenderSector);
-    assert(child.parentData is SectorParentData);
+    assert(child!.parentData is SectorParentData);
     final double maxChildDeltaRadius = math.min(constraints.maxWidth, constraints.maxHeight) / 2.0 - innerRadius;
-    child.parentData.radius = innerRadius;
-    child.parentData.theta = 0.0;
-    child.layout(SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), parentUsesSize: true);
-    final double dimension = (innerRadius + child.deltaRadius) * 2.0;
+    child!.parentData!.radius = innerRadius;
+    child!.parentData!.theta = 0.0;
+    child!.layout(SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), parentUsesSize: true);
+    final double dimension = (innerRadius + child!.deltaRadius) * 2.0;
     size = constraints.constrain(Size(dimension, dimension));
   }
 
@@ -541,12 +540,12 @@
     if (child != null) {
       final Rect bounds = offset & size;
       // we move the offset to the center of the circle for the RenderSectors
-      context.paintChild(child, bounds.center);
+      context.paintChild(child!, bounds.center);
     }
   }
 
   @override
-  bool hitTest(BoxHitTestResult result, { Offset position }) {
+  bool hitTest(BoxHitTestResult result, { required Offset position }) {
     if (child == null)
       return false;
     double x = position.dx;
@@ -559,11 +558,11 @@
     final double theta = (math.atan2(x, -y) - math.pi / 2.0) % kTwoPi;
     if (radius < innerRadius)
       return false;
-    if (radius >= innerRadius + child.deltaRadius)
+    if (radius >= innerRadius + child!.deltaRadius)
       return false;
-    if (theta > child.deltaTheta)
+    if (theta > child!.deltaTheta)
       return false;
-    child.hitTest(SectorHitTestResult.wrap(result), radius: radius, theta: theta);
+    child!.hitTest(SectorHitTestResult.wrap(result), radius: radius, theta: theta);
     result.add(BoxHitTestEntry(this, position));
     return true;
   }
@@ -634,7 +633,7 @@
   /// Creates a box hit test entry.
   ///
   /// The [radius] and [theta] argument must not be null.
-  SectorHitTestEntry(RenderSector target, { @required this.radius,  @required this.theta })
+  SectorHitTestEntry(RenderSector target, { required this.radius,  required this.theta })
       : assert(radius != null),
         assert(theta != null),
         super(target);
diff --git a/packages/flutter/lib/src/cupertino/context_menu.dart b/packages/flutter/lib/src/cupertino/context_menu.dart
index a74d104..eaeb4e5 100644
--- a/packages/flutter/lib/src/cupertino/context_menu.dart
+++ b/packages/flutter/lib/src/cupertino/context_menu.dart
@@ -731,7 +731,7 @@
   }
 
   @override
-  bool didPop(T result) {
+  bool didPop(T? result) {
     _updateTweenRects();
     return super.didPop(result);
   }
diff --git a/packages/flutter/lib/src/cupertino/route.dart b/packages/flutter/lib/src/cupertino/route.dart
index ace6af9..d1ddf5d 100644
--- a/packages/flutter/lib/src/cupertino/route.dart
+++ b/packages/flutter/lib/src/cupertino/route.dart
@@ -1049,7 +1049,7 @@
 ///  * [CupertinoActionSheet], which is the widget usually returned by the
 ///    `builder` argument to [showCupertinoModalPopup].
 ///  * <https://developer.apple.com/design/human-interface-guidelines/ios/views/action-sheets/>
-Future<T> showCupertinoModalPopup<T>({
+Future<T?> showCupertinoModalPopup<T>({
   required BuildContext context,
   required WidgetBuilder builder,
   ImageFilter? filter,
@@ -1134,7 +1134,7 @@
 ///  * [showDialog], which displays a Material-style dialog.
 ///  * [showGeneralDialog], which allows for customization of the dialog popup.
 ///  * <https://developer.apple.com/ios/human-interface-guidelines/views/alerts/>
-Future<T> showCupertinoDialog<T>({
+Future<T?> showCupertinoDialog<T>({
   required BuildContext context,
   required WidgetBuilder builder,
   bool useRootNavigator = true,
diff --git a/packages/flutter/lib/src/cupertino/tab_scaffold.dart b/packages/flutter/lib/src/cupertino/tab_scaffold.dart
index 2c65a09..306a6ec 100644
--- a/packages/flutter/lib/src/cupertino/tab_scaffold.dart
+++ b/packages/flutter/lib/src/cupertino/tab_scaffold.dart
@@ -619,8 +619,9 @@
   }
 
   @override
-  CupertinoTabController fromPrimitives(Object data) {
-    return CupertinoTabController(initialIndex: data as int);
+  CupertinoTabController fromPrimitives(Object? data) {
+    assert(data != null);
+    return CupertinoTabController(initialIndex: data! as int);
   }
 
   @override
diff --git a/packages/flutter/lib/src/cupertino/text_selection.dart b/packages/flutter/lib/src/cupertino/text_selection.dart
index 90e51e6..b2c86d2 100644
--- a/packages/flutter/lib/src/cupertino/text_selection.dart
+++ b/packages/flutter/lib/src/cupertino/text_selection.dart
@@ -781,7 +781,7 @@
     }
     if (slot is IndexedSlot) {
       assert(renderObject.debugValidateChild(child));
-      renderObject.insert(child as RenderBox, after: slot.value?.renderObject as RenderBox);
+      renderObject.insert(child as RenderBox, after: slot.value?.renderObject as RenderBox?);
       return;
     }
     assert(false, 'slot must be _CupertinoTextSelectionToolbarItemsSlot or IndexedSlot');
@@ -1255,4 +1255,4 @@
 class _NullWidget extends Widget {
   @override
   Element createElement() => throw UnimplementedError();
-}
\ No newline at end of file
+}
diff --git a/packages/flutter/lib/src/foundation/collections.dart b/packages/flutter/lib/src/foundation/collections.dart
index d6f9f8f..d62b156 100644
--- a/packages/flutter/lib/src/foundation/collections.dart
+++ b/packages/flutter/lib/src/foundation/collections.dart
@@ -166,7 +166,7 @@
   final int firstLength = middle - start;
   final int secondLength = end - middle;
   // secondLength is always the same as firstLength, or one greater.
-  final List<T?> scratchSpace = List<T?>.filled(secondLength, null, growable: false);
+  final List<T> scratchSpace = List<T>.filled(secondLength, list[start]);
   _mergeSort<T>(list, compare, middle, end, scratchSpace, 0);
   final int firstTarget = end - firstLength;
   _mergeSort<T>(list, compare, start, middle, list, firstTarget);
@@ -273,7 +273,7 @@
     int Function(T, T) compare,
     int start,
     int end,
-    List<T?> target,
+    List<T> target,
     int targetOffset,
     ) {
   final int length = end - start;
@@ -316,10 +316,10 @@
   List<T> firstList,
   int firstStart,
   int firstEnd,
-  List<T?> secondList,
+  List<T> secondList,
   int secondStart,
   int secondEnd,
-  List<T?> target,
+  List<T> target,
   int targetOffset,
 ) {
   // No empty lists reaches here.
@@ -328,7 +328,7 @@
   int cursor1 = firstStart;
   int cursor2 = secondStart;
   T firstElement = firstList[cursor1++];
-  T secondElement = secondList[cursor2++] as T;
+  T secondElement = secondList[cursor2++];
   while (true) {
     if (compare(firstElement, secondElement) <= 0) {
       target[targetOffset++] = firstElement;
@@ -340,7 +340,7 @@
     } else {
       target[targetOffset++] = secondElement;
       if (cursor2 != secondEnd) {
-        secondElement = secondList[cursor2++] as T;
+        secondElement = secondList[cursor2++];
         continue;
       }
       // Second list empties first. Flushing first list here.
diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart
index 57dd8a2..0087473 100644
--- a/packages/flutter/lib/src/material/bottom_sheet.dart
+++ b/packages/flutter/lib/src/material/bottom_sheet.dart
@@ -644,7 +644,7 @@
 ///  * [DraggableScrollableSheet], which allows you to create a bottom sheet
 ///    that grows and then becomes scrollable once it reaches its maximum size.
 ///  * <https://material.io/design/components/sheets-bottom.html#modal-bottom-sheet>
-Future<T> showModalBottomSheet<T>({
+Future<T?> showModalBottomSheet<T>({
   required BuildContext context,
   required WidgetBuilder builder,
   Color? backgroundColor,
diff --git a/packages/flutter/lib/src/material/dialog.dart b/packages/flutter/lib/src/material/dialog.dart
index a944f75..7b93e5d 100644
--- a/packages/flutter/lib/src/material/dialog.dart
+++ b/packages/flutter/lib/src/material/dialog.dart
@@ -955,7 +955,7 @@
 ///  * [showCupertinoDialog], which displays an iOS-style dialog.
 ///  * [showGeneralDialog], which allows for customization of the dialog popup.
 ///  * <https://material.io/design/components/dialogs.html>
-Future<T> showDialog<T>({
+Future<T?> showDialog<T>({
   required BuildContext context,
   WidgetBuilder? builder,
   bool barrierDismissible = true,
diff --git a/packages/flutter/lib/src/material/material_state.dart b/packages/flutter/lib/src/material/material_state.dart
index 9403b75..59f7eda 100644
--- a/packages/flutter/lib/src/material/material_state.dart
+++ b/packages/flutter/lib/src/material/material_state.dart
@@ -120,7 +120,7 @@
 /// }
 /// ```
 /// {@end-tool}
-abstract class MaterialStateColor extends Color implements MaterialStateProperty<Color?> {
+abstract class MaterialStateColor extends Color implements MaterialStateProperty<Color> {
   /// Creates a [MaterialStateColor].
   const MaterialStateColor(int defaultValue) : super(defaultValue);
 
diff --git a/packages/flutter/lib/src/material/pickers/date_picker_dialog.dart b/packages/flutter/lib/src/material/pickers/date_picker_dialog.dart
index 45fe8b4..5c11427 100644
--- a/packages/flutter/lib/src/material/pickers/date_picker_dialog.dart
+++ b/packages/flutter/lib/src/material/pickers/date_picker_dialog.dart
@@ -99,7 +99,7 @@
 ///  * [CalendarDatePicker], which provides the calendar grid used by the date picker dialog.
 ///  * [InputDatePickerFormField], which provides a text input field for entering dates.
 ///
-Future<DateTime> showDatePicker({
+Future<DateTime?> showDatePicker({
   required BuildContext context,
   required DateTime initialDate,
   required DateTime firstDate,
diff --git a/packages/flutter/lib/src/material/pickers/date_range_picker_dialog.dart b/packages/flutter/lib/src/material/pickers/date_range_picker_dialog.dart
index 6e5042e..9b5ce42 100644
--- a/packages/flutter/lib/src/material/pickers/date_range_picker_dialog.dart
+++ b/packages/flutter/lib/src/material/pickers/date_range_picker_dialog.dart
@@ -105,7 +105,7 @@
 ///    select a single date.
 ///  * [DateTimeRange], which is used to describe a date range.
 ///
-Future<DateTimeRange> showDateRangePicker({
+Future<DateTimeRange?> showDateRangePicker({
   required BuildContext context,
   DateTimeRange? initialDateRange,
   required DateTime firstDate,
diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart
index 47263dd..7c4df12 100644
--- a/packages/flutter/lib/src/material/popup_menu.dart
+++ b/packages/flutter/lib/src/material/popup_menu.dart
@@ -829,7 +829,7 @@
 ///    calling this method automatically.
 ///  * [SemanticsConfiguration.namesRoute], for a description of edge triggered
 ///    semantics.
-Future<T> showMenu<T>({
+Future<T?> showMenu<T>({
   required BuildContext context,
   required RelativeRect position,
   required List<PopupMenuEntry<T>> items,
@@ -1088,7 +1088,7 @@
     final List<PopupMenuEntry<T>> items = widget.itemBuilder(context);
     // Only show the menu if there is something to show
     if (items.isNotEmpty) {
-      showMenu<T>(
+      showMenu<T?>(
         context: context,
         elevation: widget.elevation ?? popupMenuTheme.elevation,
         items: items,
@@ -1098,7 +1098,7 @@
         color: widget.color ?? popupMenuTheme.color,
         captureInheritedThemes: widget.captureInheritedThemes,
       )
-      .then<void>((T newValue) {
+      .then<void>((T? newValue) {
         if (!mounted)
           return null;
         if (newValue == null) {
diff --git a/packages/flutter/lib/src/material/search.dart b/packages/flutter/lib/src/material/search.dart
index 0e4aeb9..e4e8996 100644
--- a/packages/flutter/lib/src/material/search.dart
+++ b/packages/flutter/lib/src/material/search.dart
@@ -49,7 +49,7 @@
 /// See also:
 ///
 ///  * [SearchDelegate] to define the content of the search page.
-Future<T> showSearch<T>({
+Future<T?> showSearch<T>({
   required BuildContext context,
   required SearchDelegate<T> delegate,
   String? query = '',
@@ -387,7 +387,7 @@
   }
 
   @override
-  void didComplete(T result) {
+  void didComplete(T? result) {
     super.didComplete(result);
     assert(delegate._route == this);
     delegate._route = null;
diff --git a/packages/flutter/lib/src/material/time_picker.dart b/packages/flutter/lib/src/material/time_picker.dart
index d4e46c1..1b465e5 100644
--- a/packages/flutter/lib/src/material/time_picker.dart
+++ b/packages/flutter/lib/src/material/time_picker.dart
@@ -2175,7 +2175,7 @@
 ///    date picker.
 ///  * [TimePickerThemeData], which allows you to customize the colors,
 ///    typography, and shape of the time picker.
-Future<TimeOfDay> showTimePicker({
+Future<TimeOfDay?> showTimePicker({
   required BuildContext context,
   required TimeOfDay initialTime,
   TransitionBuilder? builder,
diff --git a/packages/flutter/lib/src/painting/image_provider.dart b/packages/flutter/lib/src/painting/image_provider.dart
index 110ca73..8ccae23 100644
--- a/packages/flutter/lib/src/painting/image_provider.dart
+++ b/packages/flutter/lib/src/painting/image_provider.dart
@@ -379,12 +379,12 @@
   /// [FlutterError.onError], and the method will return null.
   ///
   /// A completed return value of null indicates that an error has occurred.
-  Future<ImageCacheStatus> obtainCacheStatus({
+  Future<ImageCacheStatus?> obtainCacheStatus({
     required ImageConfiguration configuration,
     ImageErrorListener? handleError,
   }) {
     assert(configuration != null);
-    final Completer<ImageCacheStatus> completer = Completer<ImageCacheStatus>();
+    final Completer<ImageCacheStatus?> completer = Completer<ImageCacheStatus?>();
     _createErrorHandlerAndKey(
       configuration,
       (T key, ImageErrorListener innerHandleError) {
diff --git a/packages/flutter/lib/src/rendering/table.dart b/packages/flutter/lib/src/rendering/table.dart
index 476def3..35174c4 100644
--- a/packages/flutter/lib/src/rendering/table.dart
+++ b/packages/flutter/lib/src/rendering/table.dart
@@ -390,7 +390,7 @@
        _textBaseline = textBaseline,
        _defaultVerticalAlignment = defaultVerticalAlignment,
        _configuration = configuration {
-    _children = <RenderBox>[]..length = _columns * _rows;
+    _children = <RenderBox?>[]..length = _columns * _rows;
     this.rowDecorations = rowDecorations; // must use setter to initialize box painters array
     children?.forEach(addRow);
   }
@@ -645,7 +645,7 @@
     // update our internal values
     _columns = columns;
     _rows = cells.length ~/ columns;
-    _children = cells.toList();
+    _children = List<RenderBox?>.from(cells);
     assert(_children.length == rows * columns);
     markNeedsLayout();
   }
diff --git a/packages/flutter/lib/src/services/restoration.dart b/packages/flutter/lib/src/services/restoration.dart
index 42e33ee..54d9a94 100644
--- a/packages/flutter/lib/src/services/restoration.dart
+++ b/packages/flutter/lib/src/services/restoration.dart
@@ -151,13 +151,13 @@
       return SynchronousFuture<RestorationBucket?>(_rootBucket);
     }
     if (_pendingRootBucket == null) {
-      _pendingRootBucket = Completer<RestorationBucket>();
+      _pendingRootBucket = Completer<RestorationBucket?>();
       _getRootBucketFromEngine();
     }
     return _pendingRootBucket!.future;
   }
   RestorationBucket? _rootBucket; // May be null to indicate that restoration is turned off.
-  Completer<RestorationBucket>? _pendingRootBucket;
+  Completer<RestorationBucket?>? _pendingRootBucket;
   bool _rootBucketIsValid = false;
 
   /// Returns true for the frame after [rootBucket] has been replaced with a
@@ -186,7 +186,7 @@
   void _parseAndHandleRestorationUpdateFromEngine(Map<dynamic, dynamic>? update) {
     handleRestorationUpdateFromEngine(
       enabled: update != null && update['enabled'] as bool,
-      data: update == null ? null : update['data'] as Uint8List,
+      data: update == null ? null : update['data'] as Uint8List?,
     );
   }
 
@@ -580,10 +580,10 @@
   ///  * [remove], which removes a value from the bucket.
   ///  * [contains], which checks whether any value is stored under a given
   ///    restoration ID.
-  P read<P>(String restorationId) {
+  P? read<P>(String restorationId) {
     assert(_debugAssertNotDisposed());
     assert(restorationId != null);
-    return _rawValues[restorationId] as P;
+    return _rawValues[restorationId] as P?;
   }
 
   /// Stores the provided `value` of type `P` under the provided `restorationId`
@@ -624,11 +624,11 @@
   ///  * [write], which stores a value in the bucket.
   ///  * [contains], which checks whether any value is stored under a given
   ///    restoration ID.
-  P remove<P>(String restorationId) {
+  P? remove<P>(String restorationId) {
     assert(_debugAssertNotDisposed());
     assert(restorationId != null);
     final bool needsUpdate = _rawValues.containsKey(restorationId);
-    final P result = _rawValues.remove(restorationId) as P;
+    final P? result = _rawValues.remove(restorationId) as P?;
     if (_rawValues.isEmpty) {
       _rawData.remove(_valuesMapKey);
     }
diff --git a/packages/flutter/lib/src/widgets/dismissible.dart b/packages/flutter/lib/src/widgets/dismissible.dart
index 799880c..b6c823f 100644
--- a/packages/flutter/lib/src/widgets/dismissible.dart
+++ b/packages/flutter/lib/src/widgets/dismissible.dart
@@ -28,7 +28,7 @@
 /// confirm or veto a dismiss gesture.
 ///
 /// Used by [Dismissible.confirmDismiss].
-typedef ConfirmDismissCallback = Future<bool> Function(DismissDirection direction);
+typedef ConfirmDismissCallback = Future<bool?> Function(DismissDirection direction);
 
 /// The direction in which a [Dismissible] can be dismissed.
 enum DismissDirection {
@@ -120,7 +120,7 @@
   /// If the returned Future<bool> completes true, then this widget will be
   /// dismissed, otherwise it will be moved back to its original location.
   ///
-  /// If the returned Future<bool> completes to false or null the [onResize]
+  /// If the returned Future<bool?> completes to false or null the [onResize]
   /// and [onDismissed] callbacks will not run.
   final ConfirmDismissCallback? confirmDismiss;
 
@@ -458,7 +458,7 @@
     updateKeepAlive();
   }
 
-  Future<bool> _confirmStartResizeAnimation() async {
+  Future<bool?> _confirmStartResizeAnimation() async {
     if (widget.confirmDismiss != null) {
       final DismissDirection direction = _dismissDirection!;
       assert(direction != null);
diff --git a/packages/flutter/lib/src/widgets/heroes.dart b/packages/flutter/lib/src/widgets/heroes.dart
index f7377cd..572beb1 100644
--- a/packages/flutter/lib/src/widgets/heroes.dart
+++ b/packages/flutter/lib/src/widgets/heroes.dart
@@ -300,7 +300,7 @@
           // the Hero is inside a nested Navigator and should only be
           // considered for animation if it is part of the top-most route in
           // that nested Navigator and if that route is also a PageRoute.
-          final ModalRoute<Object>? heroRoute = ModalRoute.of(hero);
+          final ModalRoute<Object?>? heroRoute = ModalRoute.of(hero);
           if (heroRoute != null && heroRoute is PageRoute && heroRoute.isCurrent) {
             inviteHero(hero, tag);
           }
diff --git a/packages/flutter/lib/src/widgets/localizations.dart b/packages/flutter/lib/src/widgets/localizations.dart
index ef61693..8de4803 100644
--- a/packages/flutter/lib/src/widgets/localizations.dart
+++ b/packages/flutter/lib/src/widgets/localizations.dart
@@ -450,7 +450,7 @@
     assert(context != null);
     assert(type != null);
     final _LocalizationsScope? scope = context.dependOnInheritedWidgetOfExactType<_LocalizationsScope>();
-    return scope?.localizationsState.resourcesFor<T>(type);
+    return scope?.localizationsState.resourcesFor<T?>(type);
   }
 
   @override
diff --git a/packages/flutter/lib/src/widgets/modal_barrier.dart b/packages/flutter/lib/src/widgets/modal_barrier.dart
index c4d3ce3..3d1b693 100644
--- a/packages/flutter/lib/src/widgets/modal_barrier.dart
+++ b/packages/flutter/lib/src/widgets/modal_barrier.dart
@@ -159,7 +159,7 @@
   ///
   ///  * [ModalRoute.barrierColor], which controls this property for the
   ///    [AnimatedModalBarrier] built by [ModalRoute] pages.
-  Animation<Color> get color => listenable as Animation<Color>;
+  Animation<Color?> get color => listenable as Animation<Color?>;
 
   /// Whether touching the barrier will pop the current route off the [Navigator].
   ///
diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart
index 33ad7a6..6884e89 100644
--- a/packages/flutter/lib/src/widgets/navigator.dart
+++ b/packages/flutter/lib/src/widgets/navigator.dart
@@ -306,8 +306,8 @@
   /// The future completes with the value given to [Navigator.pop], if any, or
   /// else the value of [currentResult]. See [didComplete] for more discussion
   /// on this topic.
-  Future<T> get popped => _popCompleter.future;
-  final Completer<T> _popCompleter = Completer<T>();
+  Future<T?> get popped => _popCompleter.future;
+  final Completer<T?> _popCompleter = Completer<T?>();
 
   /// A request was made to pop this route. If the route can handle it
   /// internally (e.g. because it has its own stack of internal state) then
@@ -329,7 +329,7 @@
   /// See [popped], [didComplete], and [currentResult] for a discussion of the
   /// `result` argument.
   @mustCallSuper
-  bool didPop(T result) {
+  bool didPop(T? result) {
     didComplete(result);
     return true;
   }
@@ -351,7 +351,7 @@
   /// iOS-style back gesture. See [NavigatorState.didStartUserGesture].
   @protected
   @mustCallSuper
-  void didComplete(T result) {
+  void didComplete(T? result) {
     _popCompleter.complete(result ?? currentResult);
   }
 
@@ -1693,7 +1693,7 @@
   ///  * [restorablePushNamed], which pushes a route that can be restored
   ///    during state restoration.
   @optionalTypeArgs
-  static Future<T> pushNamed<T extends Object?>(
+  static Future<T?> pushNamed<T extends Object?>(
     BuildContext context,
     String routeName, {
     Object? arguments,
@@ -1810,7 +1810,7 @@
   ///  * [restorablePushReplacementNamed], which pushes a replacement route that
   ///    can be restored during state restoration.
   @optionalTypeArgs
-  static Future<T> pushReplacementNamed<T extends Object?, TO extends Object?>(
+  static Future<T?> pushReplacementNamed<T extends Object?, TO extends Object?>(
     BuildContext context,
     String routeName, {
     TO? result,
@@ -1904,7 +1904,7 @@
   ///  * [restorablePopAndPushNamed], which pushes a new route that can be
   ///    restored during state restoration.
   @optionalTypeArgs
-  static Future<T> popAndPushNamed<T extends Object?, TO extends Object?>(
+  static Future<T?> popAndPushNamed<T extends Object?, TO extends Object?>(
     BuildContext context,
     String routeName, {
     TO? result,
@@ -2008,7 +2008,7 @@
   ///  * [restorablePushNamedAndRemoveUntil], which pushes a new route that can
   ///    be restored during state restoration.
   @optionalTypeArgs
-  static Future<T> pushNamedAndRemoveUntil<T extends Object?>(
+  static Future<T?> pushNamedAndRemoveUntil<T extends Object?>(
     BuildContext context,
     String newRouteName,
     RoutePredicate predicate, {
@@ -2087,7 +2087,7 @@
   ///  * [restorablePush], which pushes a route that can be restored during
   ///    state restoration.
   @optionalTypeArgs
-  static Future<T> push<T extends Object?>(BuildContext context, Route<T> route) {
+  static Future<T?> push<T extends Object?>(BuildContext context, Route<T> route) {
     return Navigator.of(context)!.push(route);
   }
 
@@ -2190,7 +2190,7 @@
   ///  * [restorablePushReplacement], which pushes a replacement route that can
   ///    be restored during state restoration.
   @optionalTypeArgs
-  static Future<T> pushReplacement<T extends Object?, TO extends Object?>(BuildContext context, Route<T> newRoute, { TO? result }) {
+  static Future<T?> pushReplacement<T extends Object?, TO extends Object?>(BuildContext context, Route<T> newRoute, { TO? result }) {
     return Navigator.of(context)!.pushReplacement<T, TO>(newRoute, result: result);
   }
 
@@ -2295,7 +2295,7 @@
   ///  * [restorablePushAndRemoveUntil], which pushes a route that can be
   ///    restored during state restoration.
   @optionalTypeArgs
-  static Future<T> pushAndRemoveUntil<T extends Object?>(BuildContext context, Route<T> newRoute, RoutePredicate predicate) {
+  static Future<T?> pushAndRemoveUntil<T extends Object?>(BuildContext context, Route<T> newRoute, RoutePredicate predicate) {
     return Navigator.of(context)!.pushAndRemoveUntil<T>(newRoute, predicate);
   }
 
@@ -2876,7 +2876,7 @@
     // User-provided restoration ids of Pages are prefixed with 'p+'. Generated
     // ids for pageless routes are prefixed with 'r+' to avoid clashes.
     if (hasPage) {
-      final Page<Object> page = route.settings as Page<Object>;
+      final Page<Object?> page = route.settings as Page<Object?>;
       return page.restorationId != null ? 'p+${page.restorationId}' : null;
     }
     if (restorationInformation != null) {
@@ -4000,7 +4000,7 @@
   ///  * [restorablePushNamed], which pushes a route that can be restored
   ///    during state restoration.
   @optionalTypeArgs
-  Future<T> pushNamed<T extends Object?>(
+  Future<T?> pushNamed<T extends Object?>(
     String routeName, {
     Object? arguments,
   }) {
@@ -4067,7 +4067,7 @@
   ///  * [restorablePushReplacementNamed], which pushes a replacement route that
   ///  can be restored during state restoration.
   @optionalTypeArgs
-  Future<T> pushReplacementNamed<T extends Object?, TO extends Object?>(
+  Future<T?> pushReplacementNamed<T extends Object?, TO extends Object?>(
     String routeName, {
     TO? result,
     Object? arguments,
@@ -4137,7 +4137,7 @@
   ///  * [restorablePopAndPushNamed], which pushes a new route that can be
   ///    restored during state restoration.
   @optionalTypeArgs
-  Future<T> popAndPushNamed<T extends Object?, TO extends Object?>(
+  Future<T?> popAndPushNamed<T extends Object?, TO extends Object?>(
     String routeName, {
     TO? result,
     Object? arguments,
@@ -4200,7 +4200,7 @@
   ///  * [restorablePushNamedAndRemoveUntil], which pushes a new route that can
   ///    be restored during state restoration.
   @optionalTypeArgs
-  Future<T> pushNamedAndRemoveUntil<T extends Object?>(
+  Future<T?> pushNamedAndRemoveUntil<T extends Object?>(
     String newRouteName,
     RoutePredicate predicate, {
     Object? arguments,
@@ -4266,7 +4266,7 @@
   ///  * [restorablePush], which pushes a route that can be restored during
   ///    state restoration.
   @optionalTypeArgs
-  Future<T> push<T extends Object?>(Route<T> route) {
+  Future<T?> push<T extends Object?>(Route<T> route) {
     _pushEntry(_RouteEntry(route, initialState: _RouteLifecycle.push));
     return route.popped;
   }
@@ -4410,7 +4410,7 @@
   ///  * [restorablePushReplacement], which pushes a replacement route that can
   ///    be restored during state restoration.
   @optionalTypeArgs
-  Future<T> pushReplacement<T extends Object?, TO extends Object?>(Route<T> newRoute, { TO? result }) {
+  Future<T?> pushReplacement<T extends Object?, TO extends Object?>(Route<T> newRoute, { TO? result }) {
     assert(newRoute != null);
     assert(newRoute._navigator == null);
     _pushReplacementEntry(_RouteEntry(newRoute, initialState: _RouteLifecycle.pushReplace), result);
@@ -4516,7 +4516,7 @@
   ///  * [restorablePushAndRemoveUntil], which pushes a route that can be
   ///    restored during state restoration.
   @optionalTypeArgs
-  Future<T> pushAndRemoveUntil<T extends Object?>(Route<T> newRoute, RoutePredicate predicate) {
+  Future<T?> pushAndRemoveUntil<T extends Object?>(Route<T> newRoute, RoutePredicate predicate) {
     assert(newRoute != null);
     assert(newRoute._navigator == null);
     assert(newRoute.overlayEntries.isEmpty);
@@ -5116,9 +5116,9 @@
 
   factory _RestorationInformation.fromSerializableData(Object data) {
     assert(data != null);
-    final List<Object> casted = data as List<Object>;
+    final List<Object?> casted = data as List<Object?>;
     assert(casted.isNotEmpty);
-    final _RouteRestorationType type = _RouteRestorationType.values[casted[0] as int];
+    final _RouteRestorationType type = _RouteRestorationType.values[casted[0]! as int];
     switch (type) {
       case _RouteRestorationType.named:
         return _NamedRestorationInformation.fromSerializableData(casted.sublist(1));
@@ -5167,11 +5167,11 @@
     required this.restorationScopeId,
   }) : assert(name != null), super(_RouteRestorationType.named);
 
-  factory _NamedRestorationInformation.fromSerializableData(List<Object> data) {
+  factory _NamedRestorationInformation.fromSerializableData(List<Object?> data) {
     assert(data.length >= 2);
     return _NamedRestorationInformation(
-      restorationScopeId: data[0] as int,
-      name: data[1] as String,
+      restorationScopeId: data[0]! as int,
+      name: data[1]! as String,
       arguments: data.length > 2 ? data[2] : null,
     );
   }
@@ -5206,11 +5206,11 @@
     required this.restorationScopeId,
   }) : assert(routeBuilder != null), super(_RouteRestorationType.anonymous);
 
-  factory _AnonymousRestorationInformation.fromSerializableData(List<Object> data) {
+  factory _AnonymousRestorationInformation.fromSerializableData(List<Object?> data) {
     assert(data.length > 1);
-    final RestorableRouteBuilder routeBuilder = ui.PluginUtilities.getCallbackFromHandle(ui.CallbackHandle.fromRawHandle(data[1] as int))! as RestorableRouteBuilder;
+    final RestorableRouteBuilder routeBuilder = ui.PluginUtilities.getCallbackFromHandle(ui.CallbackHandle.fromRawHandle(data[1]! as int))! as RestorableRouteBuilder;
     return _AnonymousRestorationInformation(
-      restorationScopeId: data[0] as int,
+      restorationScopeId: data[0]! as int,
       routeBuilder: routeBuilder,
       arguments: data.length > 2 ? data[2] : null,
     );
@@ -5383,10 +5383,10 @@
   }
 
   @override
-  Map<String?, List<Object>>? fromPrimitives(Object data) {
-    final Map<dynamic, dynamic> casted = data as Map<dynamic, dynamic>;
-    return casted.map<String, List<Object>>((dynamic key, dynamic value) => MapEntry<String, List<Object>>(
-      key as String,
+  Map<String?, List<Object>>? fromPrimitives(Object? data) {
+    final Map<dynamic, dynamic> casted = data! as Map<dynamic, dynamic>;
+    return casted.map<String?, List<Object>>((dynamic key, dynamic value) => MapEntry<String?, List<Object>>(
+      key as String?,
       List<Object>.from(value as List<dynamic>, growable: true),
     ));
   }
@@ -5694,9 +5694,9 @@
   }
 
   @override
-  String fromPrimitives(Object data) {
+  String fromPrimitives(Object? data) {
     assert(data != null);
-    return data as String;
+    return data! as String;
   }
 
   bool _disposed = false;
diff --git a/packages/flutter/lib/src/widgets/restoration.dart b/packages/flutter/lib/src/widgets/restoration.dart
index e83c6ed..9fc259f 100644
--- a/packages/flutter/lib/src/widgets/restoration.dart
+++ b/packages/flutter/lib/src/widgets/restoration.dart
@@ -425,7 +425,7 @@
   /// [RestorableProperty]. Whenever new restoration data has been provided to
   /// the [RestorationMixin] the property is registered to, either this method
   /// or [createDefaultValue] is called before [initWithValue] is invoked.
-  T fromPrimitives(Object data);
+  T fromPrimitives(Object? data);
 
   /// Called by the [RestorationMixin] with the `value` returned by either
   /// [createDefaultValue] or [fromPrimitives] to set the value that this
@@ -884,7 +884,7 @@
   /// restore the internal state of a [State] object, it may be removed from the
   /// restoration data by calling this method.
   @protected
-  void unregisterFromRestoration(RestorableProperty<Object> property) {
+  void unregisterFromRestoration(RestorableProperty<Object?> property) {
     assert(property != null);
     assert(property._owner == this);
     _bucket?.remove<Object?>(property._restorationId!);
diff --git a/packages/flutter/lib/src/widgets/restoration_properties.dart b/packages/flutter/lib/src/widgets/restoration_properties.dart
index 430e6cb..3a7221e 100644
--- a/packages/flutter/lib/src/widgets/restoration_properties.dart
+++ b/packages/flutter/lib/src/widgets/restoration_properties.dart
@@ -173,9 +173,9 @@
   }
 
   @override
-  T fromPrimitives(Object serialized) {
+  T fromPrimitives(Object? serialized) {
     assert(serialized != null);
-    return serialized as T;
+    return serialized! as T;
   }
 
   @override
@@ -360,8 +360,8 @@
   }
 
   @override
-  TextEditingController fromPrimitives(Object data) {
-    return TextEditingController(text: data as String);
+  TextEditingController fromPrimitives(Object? data) {
+    return TextEditingController(text: data! as String);
   }
 
   @override
diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart
index a91d8d3..cf136f8 100644
--- a/packages/flutter/lib/src/widgets/routes.dart
+++ b/packages/flutter/lib/src/widgets/routes.dart
@@ -62,7 +62,7 @@
   bool get finishedWhenPopped => true;
 
   @override
-  bool didPop(T result) {
+  bool didPop(T? result) {
     final bool returnValue = super.didPop(result);
     assert(returnValue);
     if (finishedWhenPopped)
@@ -90,8 +90,8 @@
   /// This future completes once the animation has been dismissed. That will be
   /// after [popped], because [popped] typically completes before the animation
   /// even starts, as soon as the route is popped.
-  Future<T> get completed => _transitionCompleter.future;
-  final Completer<T> _transitionCompleter = Completer<T>();
+  Future<T?> get completed => _transitionCompleter.future;
+  final Completer<T?> _transitionCompleter = Completer<T?>();
 
   /// {@template flutter.widgets.transitionRoute.transitionDuration}
   /// The duration the transition going forwards.
@@ -235,7 +235,7 @@
   }
 
   @override
-  bool didPop(T result) {
+  bool didPop(T? result) {
     assert(_controller != null, '$runtimeType.didPop called before calling install() or after calling dispose().');
     assert(!_transitionCompleter.isCompleted, 'Cannot reuse a $runtimeType after disposing it.');
     _result = result;
@@ -631,7 +631,7 @@
   }
 
   @override
-  bool didPop(T result) {
+  bool didPop(T? result) {
     if (_localHistory != null && _localHistory!.isNotEmpty) {
       final LocalHistoryEntry entry = _localHistory!.removeLast();
       assert(entry._owner == this);
@@ -1818,7 +1818,7 @@
 ///
 ///  * [showDialog], which displays a Material-style dialog.
 ///  * [showCupertinoDialog], which displays an iOS-style dialog.
-Future<T> showGeneralDialog<T extends Object?>({
+Future<T?> showGeneralDialog<T extends Object?>({
   required BuildContext context,
   required RoutePageBuilder pageBuilder,
   bool barrierDismissible = false,
diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart
index d6ffbc3..8b3d819 100644
--- a/packages/flutter/lib/src/widgets/scrollable.dart
+++ b/packages/flutter/lib/src/widgets/scrollable.dart
@@ -1084,8 +1084,8 @@
   }
 
   @override
-  double fromPrimitives(Object data) {
-    return data as double;
+  double fromPrimitives(Object? data) {
+    return data! as double;
   }
 
   @override
diff --git a/packages/flutter/lib/src/widgets/table.dart b/packages/flutter/lib/src/widgets/table.dart
index d3e42af..ec60a50 100644
--- a/packages/flutter/lib/src/widgets/table.dart
+++ b/packages/flutter/lib/src/widgets/table.dart
@@ -303,16 +303,16 @@
   }
 
   @override
-  void insertRenderObjectChild(RenderObject child, IndexedSlot<Element>? slot) {
+  void insertRenderObjectChild(RenderObject child, dynamic slot) {
     renderObject.setupParentData(child);
   }
 
   @override
-  void moveRenderObjectChild(RenderObject child, IndexedSlot<Element>? oldSlot, IndexedSlot<Element>? newSlot) {
+  void moveRenderObjectChild(RenderObject child, dynamic oldSlot, dynamic newSlot) {
   }
 
   @override
-  void removeRenderObjectChild(RenderObject child, IndexedSlot<Element>? slot) {
+  void removeRenderObjectChild(RenderObject child, dynamic slot) {
     final TableCellParentData childParentData = child.parentData! as TableCellParentData;
     renderObject.setChild(childParentData.x!, childParentData.y!, null);
   }
diff --git a/packages/flutter/test/foundation/consolidate_response_test.dart b/packages/flutter/test/foundation/consolidate_response_test.dart
index b4775f9..b628813 100644
--- a/packages/flutter/test/foundation/consolidate_response_test.dart
+++ b/packages/flutter/test/foundation/consolidate_response_test.dart
@@ -111,7 +111,7 @@
 
       test('Notifies onBytesReceived with gzipped numbers', () async {
         response.contentLength = gzipped.length;
-        final List<int?> records = <int>[];
+        final List<int?> records = <int?>[];
         await consolidateHttpClientResponseBytes(
           response,
           onBytesReceived: (int cumulative, int? total) {
diff --git a/packages/flutter/test/foundation/diagnostics_json_test.dart b/packages/flutter/test/foundation/diagnostics_json_test.dart
index 77ad289..facc1c1 100644
--- a/packages/flutter/test/foundation/diagnostics_json_test.dart
+++ b/packages/flutter/test/foundation/diagnostics_json_test.dart
@@ -76,7 +76,7 @@
     test('subtreeDepth 1', () {
       final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 1));
       expect(result.containsKey('properties'), isFalse);
-      final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
+      final List<Map<String, Object?>> children = result['children']! as List<Map<String, Object?>>;
       expect(children[0].containsKey('children'), isFalse);
       expect(children[1].containsKey('children'), isFalse);
       expect(children[2].containsKey('children'), isFalse);
@@ -85,7 +85,7 @@
     test('subtreeDepth 5', () {
       final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 5));
       expect(result.containsKey('properties'), isFalse);
-      final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
+      final List<Map<String, Object?>> children = result['children']! as List<Map<String, Object?>>;
       expect(children[0]['children'], hasLength(0));
       expect(children[1]['children'], hasLength(3));
       expect(children[2]['children'], hasLength(0));
@@ -103,7 +103,7 @@
         subtreeDepth: 1,
       ));
       expect(result['properties'], hasLength(7));
-      final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
+      final List<Map<String, Object?>> children = result['children']! as List<Map<String, Object?>>;
       expect(children, hasLength(3));
       expect(children[0]['properties'], hasLength(0));
       expect(children[1]['properties'], hasLength(2));
@@ -119,13 +119,13 @@
         },
       ));
       expect(result['foo'], isTrue);
-      final List<Map<String, Object>> properties = result['properties']! as List<Map<String, Object>>;
+      final List<Map<String, Object?>> properties = result['properties']! as List<Map<String, Object?>>;
       expect(properties, hasLength(7));
-      expect(properties.every((Map<String, Object> property) => property['foo'] == true), isTrue);
+      expect(properties.every((Map<String, Object?> property) => property['foo'] == true), isTrue);
 
-      final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
+      final List<Map<String, Object?>> children = result['children']! as List<Map<String, Object?>>;
       expect(children, hasLength(3));
-      expect(children.every((Map<String, Object> child) => child['foo'] == true), isTrue);
+      expect(children.every((Map<String, Object?> child) => child['foo'] == true), isTrue);
     });
 
     test('filterProperties - sublist', () {
@@ -135,9 +135,9 @@
             return nodes.whereType<StringProperty>().toList();
           },
       ));
-      final List<Map<String, Object>> properties = result['properties']! as List<Map<String, Object>>;
+      final List<Map<String, Object?>> properties = result['properties']! as List<Map<String, Object?>>;
       expect(properties, hasLength(3));
-      expect(properties.every((Map<String, Object> property) => property['type'] == 'StringProperty'), isTrue);
+      expect(properties.every((Map<String, Object?> property) => property['type'] == 'StringProperty'), isTrue);
     });
 
     test('filterProperties - replace', () {
@@ -154,7 +154,7 @@
             ];
           },
       ));
-      final List<Map<String, Object>> properties = result['properties']! as List<Map<String, Object>>;
+      final List<Map<String, Object?>> properties = result['properties']! as List<Map<String, Object?>>;
       expect(properties, hasLength(1));
       expect(properties.single['name'], 'foo');
     });
@@ -166,7 +166,7 @@
             return nodes.where((DiagnosticsNode node) => node.getProperties().isEmpty).toList();
           },
       ));
-      final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
+      final List<Map<String, Object?>> children = result['children']! as List<Map<String, Object?>>;
       expect(children, hasLength(1));
     });
 
@@ -177,7 +177,7 @@
             return nodes.expand((DiagnosticsNode node) => node.getChildren()).toList();
           },
       ));
-      final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
+      final List<Map<String, Object?>> children = result['children']! as List<Map<String, Object?>>;
       expect(children, hasLength(3));
       expect(children.first['name'], 'child node B1');
     });
@@ -190,11 +190,11 @@
             return nodes.take(2).toList();
           },
       ));
-      final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
+      final List<Map<String, Object?>> children = result['children']! as List<Map<String, Object?>>;
       expect(children, hasLength(3));
       expect(children.last['truncated'], isTrue);
 
-      final List<Map<String, Object>> properties = result['properties']! as List<Map<String, Object>>;
+      final List<Map<String, Object?>> properties = result['properties']! as List<Map<String, Object?>>;
       expect(properties, hasLength(3));
       expect(properties.last['truncated'], isTrue);
     });
@@ -207,13 +207,13 @@
             return delegate.copyWith(includeProperties: false);
           },
       ));
-      final List<Map<String, Object>> properties = result['properties']! as List<Map<String, Object>>;
+      final List<Map<String, Object?>> properties = result['properties']! as List<Map<String, Object?>>;
       expect(properties, hasLength(7));
-      expect(properties.every((Map<String, Object> property) => !property.containsKey('properties')), isTrue);
+      expect(properties.every((Map<String, Object?> property) => !property.containsKey('properties')), isTrue);
 
-      final List<Map<String, Object>> children = result['children']! as List<Map<String, Object>>;
+      final List<Map<String, Object?>> children = result['children']! as List<Map<String, Object?>>;
       expect(children, hasLength(3));
-      expect(children.every((Map<String, Object> child) => !child.containsKey('properties')), isTrue);
+      expect(children.every((Map<String, Object?> child) => !child.containsKey('properties')), isTrue);
     });
   });
 }
diff --git a/packages/flutter/test/foundation/diagnostics_test.dart b/packages/flutter/test/foundation/diagnostics_test.dart
index fea0b46..a6cef4d 100644
--- a/packages/flutter/test/foundation/diagnostics_test.dart
+++ b/packages/flutter/test/foundation/diagnostics_test.dart
@@ -47,15 +47,15 @@
 
 /// Encode and decode to JSON to make sure all objects in the JSON for the
 /// [DiagnosticsNode] are valid JSON.
-Map<String, Object> simulateJsonSerialization(DiagnosticsNode node) {
-  return json.decode(json.encode(node.toJsonMap(const DiagnosticsSerializationDelegate()))) as Map<String, Object>;
+Map<String, Object?> simulateJsonSerialization(DiagnosticsNode node) {
+  return json.decode(json.encode(node.toJsonMap(const DiagnosticsSerializationDelegate()))) as Map<String, Object?>;
 }
 
 void validateNodeJsonSerialization(DiagnosticsNode node) {
   validateNodeJsonSerializationHelper(simulateJsonSerialization(node), node);
 }
 
-void validateNodeJsonSerializationHelper(Map<String, Object> json, DiagnosticsNode node) {
+void validateNodeJsonSerializationHelper(Map<String, Object?> json, DiagnosticsNode node) {
   expect(json['name'], equals(node.name));
   expect(json['showSeparator'] ?? true, equals(node.showSeparator));
   expect(json['description'], equals(node.toDescription()));
@@ -67,18 +67,18 @@
   expect(json['hasChildren'] ?? false, equals(node.getChildren().isNotEmpty));
 }
 
-void validatePropertyJsonSerialization(DiagnosticsProperty<Object> property) {
+void validatePropertyJsonSerialization(DiagnosticsProperty<Object?> property) {
   validatePropertyJsonSerializationHelper(simulateJsonSerialization(property), property);
 }
 
 void validateStringPropertyJsonSerialization(StringProperty property) {
-  final Map<String, Object> json = simulateJsonSerialization(property);
+  final Map<String, Object?> json = simulateJsonSerialization(property);
   expect(json['quoted'], equals(property.quoted));
   validatePropertyJsonSerializationHelper(json, property);
 }
 
 void validateFlagPropertyJsonSerialization(FlagProperty property) {
-  final Map<String, Object> json = simulateJsonSerialization(property);
+  final Map<String, Object?> json = simulateJsonSerialization(property);
   expect(json['ifTrue'], equals(property.ifTrue));
 
   if (property.ifTrue != null) {
@@ -96,7 +96,7 @@
 }
 
 void validateDoublePropertyJsonSerialization(DoubleProperty property) {
-  final Map<String, Object> json = simulateJsonSerialization(property);
+  final Map<String, Object?> json = simulateJsonSerialization(property);
   if (property.unit != null) {
     expect(json['unit'], equals(property.unit));
   } else {
@@ -109,7 +109,7 @@
 }
 
 void validateObjectFlagPropertyJsonSerialization(ObjectFlagProperty<Object> property) {
-  final Map<String, Object> json = simulateJsonSerialization(property);
+  final Map<String, Object?> json = simulateJsonSerialization(property);
   if (property.ifPresent != null) {
     expect(json['ifPresent'], equals(property.ifPresent));
   } else {
@@ -120,7 +120,7 @@
 }
 
 void validateIterableFlagsPropertyJsonSerialization(FlagsSummary<Object?> property) {
-  final Map<String, Object> json = simulateJsonSerialization(property);
+  final Map<String, Object?> json = simulateJsonSerialization(property);
   if (property.value.isNotEmpty) {
     expect(json['values'], equals(
       property.value.entries
@@ -135,9 +135,9 @@
 }
 
 void validateIterablePropertyJsonSerialization(IterableProperty<Object> property) {
-  final Map<String, Object> json = simulateJsonSerialization(property);
+  final Map<String, Object?> json = simulateJsonSerialization(property);
   if (property.value != null) {
-    final List<Object> valuesJson = json['values']! as List<Object>;
+    final List<Object?> valuesJson = json['values']! as List<Object?>;
     final List<String> expectedValues = property.value!.map<String>((Object value) => value.toString()).toList();
     expect(listEquals(valuesJson, expectedValues), isTrue);
   } else {
@@ -147,7 +147,7 @@
   validatePropertyJsonSerializationHelper(json, property);
 }
 
-void validatePropertyJsonSerializationHelper(final Map<String, Object> json, DiagnosticsProperty<Object> property) {
+void validatePropertyJsonSerializationHelper(final Map<String, Object?> json, DiagnosticsProperty<Object?> property) {
   if (property.defaultValue != kNoDefaultValue) {
     expect(json['defaultValue'], equals(property.defaultValue.toString()));
   } else {
@@ -1919,7 +1919,7 @@
     expect(messageProperty.name, equals('diagnostics'));
     expect(messageProperty.value, isNull);
     expect(messageProperty.showName, isTrue);
-    validatePropertyJsonSerialization(messageProperty as DiagnosticsProperty<Object>);
+    validatePropertyJsonSerialization(messageProperty as DiagnosticsProperty<Object?>);
   });
 
   test('error message style wrap test', () {
@@ -2246,7 +2246,7 @@
 
   test('DiagnosticsProperty for basic types has value in json', () {
     DiagnosticsProperty<int> intProperty = DiagnosticsProperty<int>('int1', 10);
-    Map<String, Object> json = simulateJsonSerialization(intProperty);
+    Map<String, Object?> json = simulateJsonSerialization(intProperty);
     expect(json['name'], 'int1');
     expect(json['value'], 10);
 
diff --git a/packages/flutter/test/material/app_test.dart b/packages/flutter/test/material/app_test.dart
index 428af5e..46fbcec 100644
--- a/packages/flutter/test/material/app_test.dart
+++ b/packages/flutter/test/material/app_test.dart
@@ -249,7 +249,7 @@
   });
 
   testWidgets('Return value from pop is correct', (WidgetTester tester) async {
-    late Future<Object> result;
+    late Future<Object?> result;
     await tester.pumpWidget(
         MaterialApp(
           home: Builder(
@@ -258,7 +258,7 @@
                   child: ElevatedButton(
                       child: const Text('X'),
                       onPressed: () async {
-                        result = Navigator.of(context)!.pushNamed('/a');
+                        result = Navigator.of(context)!.pushNamed<Object?>('/a');
                       },
                   ),
                 );
diff --git a/packages/flutter/test/material/date_picker_test.dart b/packages/flutter/test/material/date_picker_test.dart
index b1ea26e..e135d56 100644
--- a/packages/flutter/test/material/date_picker_test.dart
+++ b/packages/flutter/test/material/date_picker_test.dart
@@ -83,7 +83,7 @@
 
   Future<void> prepareDatePicker(
     WidgetTester tester,
-    Future<void> callback(Future<DateTime> date),
+    Future<void> callback(Future<DateTime?> date),
     { TextDirection textDirection = TextDirection.ltr }
   ) async {
     late BuildContext buttonContext;
@@ -105,7 +105,7 @@
     await tester.tap(find.text('Go'));
     expect(buttonContext, isNotNull);
 
-    final Future<DateTime> date = showDatePicker(
+    final Future<DateTime?> date = showDatePicker(
       context: buttonContext,
       initialDate: initialDate,
       firstDate: firstDate,
@@ -138,7 +138,7 @@
       cancelText = 'nope';
       confirmText = 'yep';
       helpText = 'help';
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         expect(find.text(cancelText!), findsOneWidget);
         expect(find.text(confirmText!), findsOneWidget);
         expect(find.text(helpText!), findsOneWidget);
@@ -146,21 +146,21 @@
     });
 
     testWidgets('Initial date is the default', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('OK'));
         expect(await date, DateTime(2016, DateTime.january, 15));
       });
     });
 
     testWidgets('Can cancel', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('CANCEL'));
         expect(await date, isNull);
       });
     });
 
     testWidgets('Can toggle to input entry mode', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         expect(find.byType(TextField), findsNothing);
         await tester.tap(find.byIcon(Icons.edit));
         await tester.pumpAndSettle();
@@ -169,7 +169,7 @@
     });
 
     testWidgets('Toggle to input mode keeps selected date', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('12'));
         await tester.tap(find.byIcon(Icons.edit));
         await tester.pumpAndSettle();
@@ -179,7 +179,7 @@
     });
 
     testWidgets('Switching to input mode resets input error state', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         // Enter text input mode and type an invalid date to get error.
         await tester.tap(find.byIcon(Icons.edit));
         await tester.pumpAndSettle();
@@ -438,7 +438,7 @@
 
   group('Calendar mode', () {
     testWidgets('Can select a day', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('12'));
         await tester.tap(find.text('OK'));
         expect(await date, equals(DateTime(2016, DateTime.january, 12)));
@@ -446,7 +446,7 @@
     });
 
     testWidgets('Can select a month', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(previousMonthIcon);
         await tester.pumpAndSettle(const Duration(seconds: 1));
         await tester.tap(find.text('25'));
@@ -456,7 +456,7 @@
     });
 
     testWidgets('Can select a year', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('January 2016')); // Switch to year mode.
         await tester.pump();
         await tester.tap(find.text('2018'));
@@ -467,7 +467,7 @@
 
     testWidgets('Selecting date does not change displayed month', (WidgetTester tester) async {
       initialDate = DateTime(2020, DateTime.march, 15);
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(nextMonthIcon);
         await tester.pumpAndSettle(const Duration(seconds: 1));
         expect(find.text('April 2020'), findsOneWidget);
@@ -480,7 +480,7 @@
     });
 
     testWidgets('Changing year does not change selected date', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('January 2016'));
         await tester.pump();
         await tester.tap(find.text('2018'));
@@ -491,7 +491,7 @@
     });
 
     testWidgets('Changing year does not change the month', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(nextMonthIcon);
         await tester.pumpAndSettle();
         await tester.tap(nextMonthIcon);
@@ -505,7 +505,7 @@
     });
 
     testWidgets('Can select a year and then a day', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('January 2016')); // Switch to year mode.
         await tester.pump();
         await tester.tap(find.text('2017'));
@@ -517,7 +517,7 @@
     });
 
     testWidgets('Current year is visible in year picker', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('January 2016')); // Switch to year mode.
         await tester.pump();
         expect(find.text('2016'), findsOneWidget);
@@ -528,7 +528,7 @@
       initialDate = DateTime(2017, DateTime.january, 15);
       firstDate = initialDate;
       lastDate = initialDate;
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         // Earlier than firstDate. Should be ignored.
         await tester.tap(find.text('10'));
         // Later than lastDate. Should be ignored.
@@ -543,7 +543,7 @@
       initialDate = DateTime(2017, DateTime.january, 15);
       firstDate = initialDate;
       lastDate = DateTime(2017, DateTime.february, 20);
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(nextMonthIcon);
         await tester.pumpAndSettle(const Duration(seconds: 1));
         // Shouldn't be possible to keep going into March.
@@ -555,7 +555,7 @@
       initialDate = DateTime(2017, DateTime.january, 15);
       firstDate = DateTime(2016, DateTime.december, 10);
       lastDate = initialDate;
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(previousMonthIcon);
         await tester.pumpAndSettle(const Duration(seconds: 1));
         // Shouldn't be possible to keep going into November.
@@ -567,7 +567,7 @@
       initialDate = DateTime(2018, DateTime.july, 4);
       firstDate = DateTime(2018, DateTime.june, 9);
       lastDate = DateTime(2018, DateTime.december, 15);
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('July 2018')); // Switch to year mode.
         await tester.pumpAndSettle();
         await tester.tap(find.text('2016')); // Disabled, doesn't change the year.
@@ -582,7 +582,7 @@
       initialDate = DateTime(2018, DateTime.may, 4);
       firstDate = DateTime(2016, DateTime.june, 9);
       lastDate = DateTime(2019, DateTime.january, 15);
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('May 2018'));
         await tester.pumpAndSettle();
         await tester.tap(find.text('2016'));
@@ -596,7 +596,7 @@
       initialDate = DateTime(2018, DateTime.may, 4);
       firstDate = DateTime(2016, DateTime.june, 9);
       lastDate = DateTime(2019, DateTime.january, 15);
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('May 2018'));
         await tester.pumpAndSettle();
         await tester.tap(find.text('2019'));
@@ -611,7 +611,7 @@
       firstDate = DateTime(2017, DateTime.january, 10);
       lastDate = DateTime(2017, DateTime.january, 20);
       selectableDayPredicate = (DateTime day) => day.day.isEven;
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('13')); // Odd, doesn't work.
         await tester.tap(find.text('10')); // Even, works.
         await tester.tap(find.text('17')); // Odd, doesn't work.
@@ -623,7 +623,7 @@
     testWidgets('Can select initial calendar picker mode', (WidgetTester tester) async {
       initialDate = DateTime(2014, DateTime.january, 15);
       initialCalendarMode = DatePickerMode.year;
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.pump();
         // 2018 wouldn't be available if the year picker wasn't showing.
         // The initial current year is 2014.
@@ -635,7 +635,7 @@
 
     testWidgets('currentDate is highlighted', (WidgetTester tester) async {
       today = DateTime(2016, 1, 2);
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.pump();
         const Color todayColor = Color(0xff2196f3); // default primary color
         expect(
@@ -649,7 +649,7 @@
     testWidgets('Selecting date does not switch picker to year selection', (WidgetTester tester) async {
       initialDate = DateTime(2020, DateTime.may, 10);
       initialCalendarMode = DatePickerMode.year;
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.pump();
         await tester.tap(find.text('2017'));
         await tester.pump();
@@ -671,7 +671,7 @@
     });
 
     testWidgets('Initial entry mode is used', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         expect(find.byType(TextField), findsOneWidget);
       });
     });
@@ -682,7 +682,7 @@
       fieldHintText = 'hint';
       fieldLabelText = 'label';
       helpText = 'help';
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         expect(find.text(cancelText!), findsOneWidget);
         expect(find.text(confirmText!), findsOneWidget);
         expect(find.text(fieldHintText!), findsOneWidget);
@@ -692,14 +692,14 @@
     });
 
     testWidgets('Initial date is the default', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('OK'));
         expect(await date, DateTime(2016, DateTime.january, 15));
       });
     });
 
     testWidgets('Can toggle to calendar entry mode', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         expect(find.byType(TextField), findsOneWidget);
         await tester.tap(find.byIcon(Icons.calendar_today));
         await tester.pumpAndSettle();
@@ -708,7 +708,7 @@
     });
 
     testWidgets('Toggle to calendar mode keeps selected date', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         final TextField field = textField(tester);
         field.controller!.clear();
 
@@ -721,7 +721,7 @@
     });
 
     testWidgets('Entered text returns date', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         final TextField field = textField(tester);
         field.controller!.clear();
 
@@ -733,7 +733,7 @@
 
     testWidgets('Too short entered text shows error', (WidgetTester tester) async {
       errorFormatText = 'oops';
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         final TextField field = textField(tester);
         field.controller!.clear();
 
@@ -749,7 +749,7 @@
 
     testWidgets('Bad format entered text shows error', (WidgetTester tester) async {
       errorFormatText = 'oops';
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         final TextField field = textField(tester);
         field.controller!.clear();
 
@@ -766,7 +766,7 @@
 
     testWidgets('Invalid entered text shows error', (WidgetTester tester) async {
       errorInvalidText = 'oops';
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         final TextField field = textField(tester);
         field.controller!.clear();
 
@@ -912,7 +912,7 @@
     });
 
     testWidgets('Selecting date vibrates', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('10'));
         await tester.pump(hapticFeedbackInterval);
         expect(feedback.hapticCount, 1);
@@ -926,7 +926,7 @@
     });
 
     testWidgets('Tapping unselectable date does not vibrate', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('11'));
         await tester.pump(hapticFeedbackInterval);
         expect(feedback.hapticCount, 0);
@@ -940,7 +940,7 @@
     });
 
     testWidgets('Changing modes and year vibrates', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('January 2017'));
         await tester.pump(hapticFeedbackInterval);
         expect(feedback.hapticCount, 1);
@@ -956,7 +956,7 @@
       final SemanticsHandle semantics = tester.ensureSemantics();
       addTearDown(semantics.dispose);
 
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         // Header
         expect(tester.getSemantics(find.text('SELECT DATE')), matchesSemantics(
           label: 'SELECT DATE\nFri, Jan 15',
@@ -1174,7 +1174,7 @@
       addTearDown(semantics.dispose);
 
       initialCalendarMode = DatePickerMode.year;
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         // Header
         expect(tester.getSemantics(find.text('SELECT DATE')), matchesSemantics(
           label: 'SELECT DATE\nFri, Jan 15',
@@ -1231,7 +1231,7 @@
       addTearDown(semantics.dispose);
 
       initialEntryMode = DatePickerEntryMode.input;
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         // Header
         expect(tester.getSemantics(find.text('SELECT DATE')), matchesSemantics(
           label: 'SELECT DATE\nFri, Jan 15',
@@ -1285,7 +1285,7 @@
 
   group('Keyboard navigation', () {
     testWidgets('Can toggle to calendar entry mode', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         expect(find.byType(TextField), findsNothing);
         // Navigate to the entry toggle button and activate it
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
@@ -1301,7 +1301,7 @@
     });
 
     testWidgets('Can toggle to year mode', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         expect(find.text('2016'), findsNothing);
         // Navigate to the year selector and activate it
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
@@ -1313,7 +1313,7 @@
     });
 
     testWidgets('Can navigate next/previous months', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         expect(find.text('January 2016'), findsOneWidget);
         // Navigate to the previous month button and activate it twice
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
@@ -1341,7 +1341,7 @@
     });
 
     testWidgets('Can navigate date grid with arrow keys', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         // Navigate to the grid
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
@@ -1377,7 +1377,7 @@
     });
 
     testWidgets('Navigating with arrow keys scrolls months', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         // Navigate to the grid
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
@@ -1425,7 +1425,7 @@
     });
 
     testWidgets('RTL text direction reverses the horizontal arrow key navigation', (WidgetTester tester) async {
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         // Navigate to the grid
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
@@ -1484,7 +1484,7 @@
       addTearDown(tester.binding.window.clearPhysicalSizeTestValue);
       tester.binding.window.devicePixelRatioTestValue = 1.0;
       addTearDown(tester.binding.window.clearDevicePixelRatioTestValue);
-      await prepareDatePicker(tester, (Future<DateTime> date) async {
+      await prepareDatePicker(tester, (Future<DateTime?> date) async {
         await tester.tap(find.text('OK'));
       });
       await tester.pumpAndSettle();
diff --git a/packages/flutter/test/material/date_range_picker_test.dart b/packages/flutter/test/material/date_range_picker_test.dart
index 8d1bb8a..a890021 100644
--- a/packages/flutter/test/material/date_range_picker_test.dart
+++ b/packages/flutter/test/material/date_range_picker_test.dart
@@ -52,7 +52,7 @@
 
   Future<void> preparePicker(
     WidgetTester tester,
-    Future<void> callback(Future<DateTimeRange> date),
+    Future<void> callback(Future<DateTimeRange?> date),
     { TextDirection textDirection = TextDirection.ltr }
   ) async {
     late BuildContext buttonContext;
@@ -74,7 +74,7 @@
     await tester.tap(find.text('Go'));
     expect(buttonContext, isNotNull);
 
-    final Future<DateTimeRange> range = showDateRangePicker(
+    final Future<DateTimeRange?> range = showDateRangePicker(
       context: buttonContext,
       initialDateRange: initialDateRange,
       firstDate: firstDate,
@@ -107,14 +107,14 @@
   testWidgets('Save and help text is used', (WidgetTester tester) async {
     helpText = 'help';
     saveText = 'make it so';
-    await preparePicker(tester, (Future<DateTimeRange> range) async {
+    await preparePicker(tester, (Future<DateTimeRange?> range) async {
       expect(find.text(helpText!), findsOneWidget);
       expect(find.text(saveText!), findsOneWidget);
     });
   });
 
   testWidgets('Initial date is the default', (WidgetTester tester) async {
-    await preparePicker(tester, (Future<DateTimeRange> range) async {
+    await preparePicker(tester, (Future<DateTimeRange?> range) async {
       await tester.tap(find.text('SAVE'));
       expect(await range, DateTimeRange(
         start: DateTime(2016, DateTime.january, 15),
@@ -131,7 +131,7 @@
       start: lastDate,
       end: lastDate,
     );
-    await preparePicker(tester, (Future<DateTimeRange> range) async {
+    await preparePicker(tester, (Future<DateTimeRange?> range) async {
       // December header should be showing, but no November
       expect(find.text('December 2016'), findsOneWidget);
       expect(find.text('November 2016'), findsNothing);
@@ -146,7 +146,7 @@
       start: firstDate,
       end: firstDate,
     );
-    await preparePicker(tester, (Future<DateTimeRange> range) async {
+    await preparePicker(tester, (Future<DateTimeRange?> range) async {
       // January and February headers should be showing, but no March
       expect(find.text('January 2015'), findsOneWidget);
       expect(find.text('February 2015'), findsOneWidget);
@@ -161,7 +161,7 @@
     currentDate = DateTime(2016, DateTime.september, 1);
     initialDateRange = null;
 
-    await preparePicker(tester, (Future<DateTimeRange> range) async {
+    await preparePicker(tester, (Future<DateTimeRange?> range) async {
       // September and October headers should be showing, but no August
       expect(find.text('September 2016'), findsOneWidget);
       expect(find.text('October 2016'), findsOneWidget);
@@ -170,14 +170,14 @@
   });
 
   testWidgets('Can cancel', (WidgetTester tester) async {
-    await preparePicker(tester, (Future<DateTimeRange> range) async {
+    await preparePicker(tester, (Future<DateTimeRange?> range) async {
       await tester.tap(find.byIcon(Icons.close));
       expect(await range, isNull);
     });
   });
 
   testWidgets('Can select a range', (WidgetTester tester) async {
-    await preparePicker(tester, (Future<DateTimeRange> range) async {
+    await preparePicker(tester, (Future<DateTimeRange?> range) async {
       await tester.tap(find.text('12').first);
       await tester.tap(find.text('14').first);
       await tester.tap(find.text('SAVE'));
@@ -189,7 +189,7 @@
   });
 
   testWidgets('Tapping earlier date resets selected range', (WidgetTester tester) async {
-    await preparePicker(tester, (Future<DateTimeRange> range) async {
+    await preparePicker(tester, (Future<DateTimeRange?> range) async {
       await tester.tap(find.text('12').first);
       await tester.tap(find.text('11').first);
       await tester.tap(find.text('15').first);
@@ -202,7 +202,7 @@
   });
 
   testWidgets('Can select single day range', (WidgetTester tester) async {
-    await preparePicker(tester, (Future<DateTimeRange> range) async {
+    await preparePicker(tester, (Future<DateTimeRange?> range) async {
       await tester.tap(find.text('12').first);
       await tester.tap(find.text('12').first);
       await tester.tap(find.text('SAVE'));
@@ -220,7 +220,7 @@
     );
     firstDate = DateTime(2017, DateTime.january, 12);
     lastDate = DateTime(2017, DateTime.january, 16);
-    await preparePicker(tester, (Future<DateTimeRange> range) async {
+    await preparePicker(tester, (Future<DateTimeRange?> range) async {
       // Earlier than firstDate. Should be ignored.
       await tester.tap(find.text('10'));
       // Later than lastDate. Should be ignored.
@@ -232,7 +232,7 @@
   });
 
   testWidgets('Can toggle to input entry mode', (WidgetTester tester) async {
-    await preparePicker(tester, (Future<DateTimeRange> range) async {
+    await preparePicker(tester, (Future<DateTimeRange?> range) async {
       expect(find.byType(TextField), findsNothing);
       await tester.tap(find.byIcon(Icons.edit));
       await tester.pumpAndSettle();
@@ -241,7 +241,7 @@
   });
 
   testWidgets('Toggle to input mode keeps selected date', (WidgetTester tester) async {
-    await preparePicker(tester, (Future<DateTimeRange> range) async {
+    await preparePicker(tester, (Future<DateTimeRange?> range) async {
       await tester.tap(find.text('12').first);
       await tester.tap(find.text('14').first);
       await tester.tap(find.byIcon(Icons.edit));
@@ -262,7 +262,7 @@
     testWidgets('Invalid start date', (WidgetTester tester) async {
       // Invalid start date should have neither a start nor end date selected in
       // calendar mode
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.enterText(find.byType(TextField).at(0), '12/27/1918');
         await tester.enterText(find.byType(TextField).at(1), '12/25/2016');
         await tester.tap(find.byIcon(Icons.calendar_today));
@@ -275,7 +275,7 @@
 
     testWidgets('Invalid end date', (WidgetTester tester) async {
       // Invalid end date should only have a start date selected
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.enterText(find.byType(TextField).at(0), '12/24/2016');
         await tester.enterText(find.byType(TextField).at(1), '12/25/2050');
         await tester.tap(find.byIcon(Icons.calendar_today));
@@ -288,7 +288,7 @@
 
     testWidgets('Invalid range', (WidgetTester tester) async {
       // Start date after end date should just use the start date
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.enterText(find.byType(TextField).at(0), '12/25/2016');
         await tester.enterText(find.byType(TextField).at(1), '12/24/2016');
         await tester.tap(find.byIcon(Icons.calendar_today));
@@ -375,7 +375,7 @@
     });
 
     testWidgets('Selecting dates vibrates', (WidgetTester tester) async {
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.tap(find.text('10').first);
         await tester.pump(hapticFeedbackInterval);
         expect(feedback.hapticCount, 1);
@@ -389,7 +389,7 @@
     });
 
     testWidgets('Tapping unselectable date does not vibrate', (WidgetTester tester) async {
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.tap(find.text('8').first);
         await tester.pump(hapticFeedbackInterval);
         expect(feedback.hapticCount, 0);
@@ -399,7 +399,7 @@
 
   group('Keyboard navigation', () {
     testWidgets('Can toggle to calendar entry mode', (WidgetTester tester) async {
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         expect(find.byType(TextField), findsNothing);
         // Navigate to the entry toggle button and activate it
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
@@ -412,7 +412,7 @@
     });
 
     testWidgets('Can navigate date grid with arrow keys', (WidgetTester tester) async {
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         // Navigate to the grid
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
@@ -464,7 +464,7 @@
     });
 
     testWidgets('Navigating with arrow keys scrolls as needed', (WidgetTester tester) async {
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         // Jan and Feb headers should be showing, but no March
         expect(find.text('January 2016'), findsOneWidget);
         expect(find.text('February 2016'), findsOneWidget);
@@ -529,7 +529,7 @@
     });
 
     testWidgets('RTL text direction reverses the horizontal arrow key navigation', (WidgetTester tester) async {
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         // Navigate to the grid
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
         await tester.sendKeyEvent(LogicalKeyboardKey.tab);
@@ -589,7 +589,7 @@
     });
 
     testWidgets('Initial entry mode is used', (WidgetTester tester) async {
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         expect(find.byType(TextField), findsNWidgets(2));
       });
     });
@@ -603,7 +603,7 @@
       fieldStartLabelText = 'label1';
       fieldEndLabelText = 'label2';
       helpText = 'help';
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         expect(find.text(cancelText!), findsOneWidget);
         expect(find.text(confirmText!), findsOneWidget);
         expect(find.text(fieldStartHintText!), findsOneWidget);
@@ -615,7 +615,7 @@
     });
 
     testWidgets('Initial date is the default', (WidgetTester tester) async {
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.tap(find.text('OK'));
         expect(await range, DateTimeRange(
           start: DateTime(2017, DateTime.january, 15),
@@ -625,7 +625,7 @@
     });
 
     testWidgets('Can toggle to calendar entry mode', (WidgetTester tester) async {
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         expect(find.byType(TextField), findsNWidgets(2));
         await tester.tap(find.byIcon(Icons.calendar_today));
         await tester.pumpAndSettle();
@@ -635,7 +635,7 @@
 
     testWidgets('Toggle to calendar mode keeps selected date', (WidgetTester tester) async {
       initialDateRange = null;
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.enterText(find.byType(TextField).at(0), '12/25/2016');
         await tester.enterText(find.byType(TextField).at(1), '12/27/2016');
         await tester.tap(find.byIcon(Icons.calendar_today));
@@ -651,7 +651,7 @@
 
     testWidgets('Entered text returns range', (WidgetTester tester) async {
       initialDateRange = null;
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.enterText(find.byType(TextField).at(0), '12/25/2016');
         await tester.enterText(find.byType(TextField).at(1), '12/27/2016');
         await tester.tap(find.text('OK'));
@@ -666,7 +666,7 @@
     testWidgets('Too short entered text shows error', (WidgetTester tester) async {
       initialDateRange = null;
       errorFormatText = 'oops';
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.enterText(find.byType(TextField).at(0), '12/25');
         await tester.enterText(find.byType(TextField).at(1), '12/25');
         expect(find.text(errorFormatText!), findsNothing);
@@ -680,7 +680,7 @@
     testWidgets('Bad format entered text shows error', (WidgetTester tester) async {
       initialDateRange = null;
       errorFormatText = 'oops';
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.enterText(find.byType(TextField).at(0), '20202014');
         await tester.enterText(find.byType(TextField).at(1), '20212014');
         expect(find.text(errorFormatText!), findsNothing);
@@ -694,7 +694,7 @@
     testWidgets('Invalid entered text shows error', (WidgetTester tester) async {
       initialDateRange = null;
       errorInvalidText = 'oops';
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.enterText(find.byType(TextField).at(0), '08/08/2014');
         await tester.enterText(find.byType(TextField).at(1), '08/08/2014');
         expect(find.text(errorInvalidText!), findsNothing);
@@ -708,7 +708,7 @@
     testWidgets('End before start date shows error', (WidgetTester tester) async {
       initialDateRange = null;
       errorInvalidRangeText = 'oops';
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.enterText(find.byType(TextField).at(0), '12/27/2016');
         await tester.enterText(find.byType(TextField).at(1), '12/25/2016');
         expect(find.text(errorInvalidRangeText!), findsNothing);
@@ -722,7 +722,7 @@
     testWidgets('Error text only displayed for invalid date', (WidgetTester tester) async {
       initialDateRange = null;
       errorInvalidText = 'oops';
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.enterText(find.byType(TextField).at(0), '12/27/2016');
         await tester.enterText(find.byType(TextField).at(1), '01/01/2018');
         expect(find.text(errorInvalidText!), findsNothing);
@@ -735,7 +735,7 @@
 
     testWidgets('End before start date does not get passed to calendar mode', (WidgetTester tester) async {
       initialDateRange = null;
-      await preparePicker(tester, (Future<DateTimeRange> range) async {
+      await preparePicker(tester, (Future<DateTimeRange?> range) async {
         await tester.enterText(find.byType(TextField).at(0), '12/27/2016');
         await tester.enterText(find.byType(TextField).at(1), '12/25/2016');
 
diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart
index cc54bbd..212c499 100644
--- a/packages/flutter/test/material/dialog_test.dart
+++ b/packages/flutter/test/material/dialog_test.dart
@@ -233,7 +233,7 @@
 
     final BuildContext context = tester.element(find.text('Go'));
 
-    final Future<int> result = showDialog<int>(
+    final Future<int?> result = showDialog<int>(
       context: context,
       builder: (BuildContext context) {
         return SimpleDialog(
@@ -273,7 +273,7 @@
       ),
     );
 
-    final Future<int> result = showDialog<int>(
+    final Future<int?> result = showDialog<int>(
       context: navigator.currentContext!,
       builder: (BuildContext context) {
         return SimpleDialog(
@@ -1382,7 +1382,7 @@
     final List<int> dismissedItems = <int>[];
 
     // Dismiss is confirmed IFF confirmDismiss() returns true.
-    Future<bool> confirmDismiss (DismissDirection dismissDirection) {
+    Future<bool?> confirmDismiss (DismissDirection dismissDirection) async {
       return showDialog<bool>(
         context: _scaffoldKey.currentContext!,
         barrierDismissible: true, // showDialog() returns null if tapped outside the dialog
@@ -1762,7 +1762,7 @@
     final BuildContext context = tester.element(find.text('Go'));
     const RouteSettings exampleSetting = RouteSettings(name: 'simple');
 
-    final Future<int> result = showDialog<int>(
+    final Future<int?> result = showDialog<int>(
       context: context,
       builder: (BuildContext context) {
         return SimpleDialog(
diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart
index 5347310..d4f5be8 100644
--- a/packages/flutter/test/material/popup_menu_test.dart
+++ b/packages/flutter/test/material/popup_menu_test.dart
@@ -465,7 +465,7 @@
     final WidgetPredicate popupMenu = (Widget widget) {
       final String widgetType = widget.runtimeType.toString();
       // TODO(mraleph): Remove the old case below.
-      return widgetType == '_PopupMenu<int>' // normal case
+      return widgetType == '_PopupMenu<int?>' // normal case
           || widgetType == '_PopupMenu'; // for old versions of Dart that don't reify method type arguments
     };
 
@@ -794,7 +794,7 @@
     await tester.pumpAndSettle();
 
     // The position is different than the offset because the default position isn't at the origin.
-    expect(tester.getTopLeft(find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_PopupMenu<int>')), const Offset(364.0, 324.0));
+    expect(tester.getTopLeft(find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_PopupMenu<int?>')), const Offset(364.0, 324.0));
   });
 
   testWidgets('open PopupMenu has correct semantics', (WidgetTester tester) async {
diff --git a/packages/flutter/test/material/search_test.dart b/packages/flutter/test/material/search_test.dart
index fd73035..9345317 100644
--- a/packages/flutter/test/material/search_test.dart
+++ b/packages/flutter/test/material/search_test.dart
@@ -80,7 +80,7 @@
     // regression test for https://github.com/flutter/flutter/issues/18145
 
     final _TestSearchDelegate delegate = _TestSearchDelegate();
-    final List<String> selectedResults = <String>[];
+    final List<String?> selectedResults = <String?>[];
 
     await tester.pumpWidget(TestHomePage(
       delegate: delegate,
@@ -105,7 +105,7 @@
     await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/navigation', message, (_) { });
     await tester.pumpAndSettle();
 
-    expect(selectedResults, <void>[null]);
+    expect(selectedResults, <String?>[null]);
 
     // We are on the homepage again
     expect(find.text('HomeBody'), findsOneWidget);
@@ -374,7 +374,7 @@
   });
 
   testWidgets('Closing nested search returns to search', (WidgetTester tester) async {
-    final List<String> nestedSearchResults = <String>[];
+    final List<String?> nestedSearchResults = <String?>[];
     final _TestSearchDelegate nestedSearchDelegate = _TestSearchDelegate(
       suggestions: 'Nested Suggestions',
       result: 'Nested Result',
@@ -389,7 +389,7 @@
               tooltip: 'Nested Search',
               icon: const Icon(Icons.search),
               onPressed: () async {
-                final String result = await showSearch(
+                final String? result = await showSearch(
                   context: context,
                   delegate: nestedSearchDelegate,
                 );
@@ -467,7 +467,7 @@
               tooltip: 'Nested Search',
               icon: const Icon(Icons.search),
               onPressed: () async {
-                final String result = await showSearch(
+                final String? result = await showSearch(
                   context: context,
                   delegate: nestedSearchDelegate,
                 );
@@ -702,7 +702,7 @@
     this.initialQuery,
   }) : super(key: key);
 
-  final List<String>? results;
+  final List<String?>? results;
   final SearchDelegate<String> delegate;
   final bool passInInitialQuery;
   final String? initialQuery;
@@ -719,7 +719,7 @@
                 tooltip: 'Search',
                 icon: const Icon(Icons.search),
                 onPressed: () async {
-                  String selectedResult;
+                  String? selectedResult;
                   if (passInInitialQuery) {
                     selectedResult = await showSearch<String>(
                       context: context,
diff --git a/packages/flutter/test/material/time_picker_test.dart b/packages/flutter/test/material/time_picker_test.dart
index 1296104..cc13240 100644
--- a/packages/flutter/test/material/time_picker_test.dart
+++ b/packages/flutter/test/material/time_picker_test.dart
@@ -23,7 +23,7 @@
     this.entryMode = TimePickerEntryMode.dial,
   }) : super(key: key);
 
-  final ValueChanged<TimeOfDay> onChanged;
+  final ValueChanged<TimeOfDay?> onChanged;
   final Locale? locale;
   final TimePickerEntryMode entryMode;
 
@@ -55,7 +55,7 @@
 
 Future<Offset?> startPicker(
     WidgetTester tester,
-    ValueChanged<TimeOfDay> onChanged, {
+    ValueChanged<TimeOfDay?> onChanged, {
       TimePickerEntryMode entryMode = TimePickerEntryMode.dial,
     }) async {
   await tester.pumpWidget(_TimePickerLauncher(onChanged: onChanged, locale: const Locale('en', 'US'), entryMode: entryMode));
@@ -82,24 +82,24 @@
 
 void _tests() {
   testWidgets('tap-select an hour', (WidgetTester tester) async {
-    late TimeOfDay result;
+    TimeOfDay? result;
 
-    Offset center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
+    Offset center = (await startPicker(tester, (TimeOfDay? time) { result = time; }))!;
     await tester.tapAt(Offset(center.dx, center.dy - 50.0)); // 12:00 AM
     await finishPicker(tester);
     expect(result, equals(const TimeOfDay(hour: 0, minute: 0)));
 
-    center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
+    center = (await startPicker(tester, (TimeOfDay? time) { result = time; }))!;
     await tester.tapAt(Offset(center.dx + 50.0, center.dy));
     await finishPicker(tester);
     expect(result, equals(const TimeOfDay(hour: 3, minute: 0)));
 
-    center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
+    center = (await startPicker(tester, (TimeOfDay? time) { result = time; }))!;
     await tester.tapAt(Offset(center.dx, center.dy + 50.0));
     await finishPicker(tester);
     expect(result, equals(const TimeOfDay(hour: 6, minute: 0)));
 
-    center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
+    center = (await startPicker(tester, (TimeOfDay? time) { result = time; }))!;
     await tester.tapAt(Offset(center.dx, center.dy + 50.0));
     await tester.tapAt(Offset(center.dx - 50, center.dy));
     await finishPicker(tester);
@@ -109,7 +109,7 @@
   testWidgets('drag-select an hour', (WidgetTester tester) async {
     late TimeOfDay result;
 
-    final Offset center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
+    final Offset center = (await startPicker(tester, (TimeOfDay? time) { result = time!; }))!;
     final Offset hour0 = Offset(center.dx, center.dy - 50.0); // 12:00 AM
     final Offset hour3 = Offset(center.dx + 50.0, center.dy);
     final Offset hour6 = Offset(center.dx, center.dy + 50.0);
@@ -123,21 +123,21 @@
     await finishPicker(tester);
     expect(result.hour, 0);
 
-    expect(await startPicker(tester, (TimeOfDay time) { result = time; }), equals(center));
+    expect(await startPicker(tester, (TimeOfDay? time) { result = time!; }), equals(center));
     gesture = await tester.startGesture(hour0);
     await gesture.moveBy(hour3 - hour0);
     await gesture.up();
     await finishPicker(tester);
     expect(result.hour, 3);
 
-    expect(await startPicker(tester, (TimeOfDay time) { result = time; }), equals(center));
+    expect(await startPicker(tester, (TimeOfDay? time) { result = time!; }), equals(center));
     gesture = await tester.startGesture(hour3);
     await gesture.moveBy(hour6 - hour3);
     await gesture.up();
     await finishPicker(tester);
     expect(result.hour, equals(6));
 
-    expect(await startPicker(tester, (TimeOfDay time) { result = time; }), equals(center));
+    expect(await startPicker(tester, (TimeOfDay? time) { result = time!; }), equals(center));
     gesture = await tester.startGesture(hour6);
     await gesture.moveBy(hour9 - hour6);
     await gesture.up();
@@ -148,7 +148,7 @@
   testWidgets('tap-select switches from hour to minute', (WidgetTester tester) async {
     late TimeOfDay result;
 
-    final Offset center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
+    final Offset center = (await startPicker(tester, (TimeOfDay? time) { result = time!; }))!;
     final Offset hour6 = Offset(center.dx, center.dy + 50.0); // 6:00
     final Offset min45 = Offset(center.dx - 50.0, center.dy); // 45 mins (or 9:00 hours)
 
@@ -162,7 +162,7 @@
   testWidgets('drag-select switches from hour to minute', (WidgetTester tester) async {
     late TimeOfDay result;
 
-    final Offset center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
+    final Offset center = (await startPicker(tester, (TimeOfDay? time) { result = time!; }))!;
     final Offset hour3 = Offset(center.dx + 50.0, center.dy);
     final Offset hour6 = Offset(center.dx, center.dy + 50.0);
     final Offset hour9 = Offset(center.dx - 50.0, center.dy);
@@ -181,7 +181,7 @@
   testWidgets('tap-select rounds down to nearest 5 minute increment', (WidgetTester tester) async {
     late TimeOfDay result;
 
-    final Offset center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
+    final Offset center = (await startPicker(tester, (TimeOfDay? time) { result = time!; }))!;
     final Offset hour6 = Offset(center.dx, center.dy + 50.0); // 6:00
     final Offset min46 = Offset(center.dx - 50.0, center.dy - 5); // 46 mins
 
@@ -195,7 +195,7 @@
   testWidgets('tap-select rounds up to nearest 5 minute increment', (WidgetTester tester) async {
     late TimeOfDay result;
 
-    final Offset center = (await startPicker(tester, (TimeOfDay time) { result = time; }))!;
+    final Offset center = (await startPicker(tester, (TimeOfDay? time) { result = time!; }))!;
     final Offset hour6 = Offset(center.dx, center.dy + 50.0); // 6:00
     final Offset min48 = Offset(center.dx - 50.0, center.dy - 15); // 48 mins
 
@@ -220,14 +220,14 @@
     });
 
     testWidgets('tap-select vibrates once', (WidgetTester tester) async {
-      final Offset center = (await startPicker(tester, (TimeOfDay time) { }))!;
+      final Offset center = (await startPicker(tester, (TimeOfDay? time) { }))!;
       await tester.tapAt(Offset(center.dx, center.dy - 50.0));
       await finishPicker(tester);
       expect(feedback.hapticCount, 1);
     });
 
     testWidgets('quick successive tap-selects vibrate once', (WidgetTester tester) async {
-      final Offset center = (await startPicker(tester, (TimeOfDay time) { }))!;
+      final Offset center = (await startPicker(tester, (TimeOfDay? time) { }))!;
       await tester.tapAt(Offset(center.dx, center.dy - 50.0));
       await tester.pump(kFastFeedbackInterval);
       await tester.tapAt(Offset(center.dx, center.dy + 50.0));
@@ -236,7 +236,7 @@
     });
 
     testWidgets('slow successive tap-selects vibrate once per tap', (WidgetTester tester) async {
-      final Offset center = (await startPicker(tester, (TimeOfDay time) { }))!;
+      final Offset center = (await startPicker(tester, (TimeOfDay? time) { }))!;
       await tester.tapAt(Offset(center.dx, center.dy - 50.0));
       await tester.pump(kSlowFeedbackInterval);
       await tester.tapAt(Offset(center.dx, center.dy + 50.0));
@@ -247,7 +247,7 @@
     });
 
     testWidgets('drag-select vibrates once', (WidgetTester tester) async {
-      final Offset center = (await startPicker(tester, (TimeOfDay time) { }))!;
+      final Offset center = (await startPicker(tester, (TimeOfDay? time) { }))!;
       final Offset hour0 = Offset(center.dx, center.dy - 50.0);
       final Offset hour3 = Offset(center.dx + 50.0, center.dy);
 
@@ -259,7 +259,7 @@
     });
 
     testWidgets('quick drag-select vibrates once', (WidgetTester tester) async {
-      final Offset center = (await startPicker(tester, (TimeOfDay time) { }))!;
+      final Offset center = (await startPicker(tester, (TimeOfDay? time) { }))!;
       final Offset hour0 = Offset(center.dx, center.dy - 50.0);
       final Offset hour3 = Offset(center.dx + 50.0, center.dy);
 
@@ -275,7 +275,7 @@
     });
 
     testWidgets('slow drag-select vibrates once', (WidgetTester tester) async {
-      final Offset center = (await startPicker(tester, (TimeOfDay time) { }))!;
+      final Offset center = (await startPicker(tester, (TimeOfDay? time) { }))!;
       final Offset hour0 = Offset(center.dx, center.dy - 50.0);
       final Offset hour3 = Offset(center.dx + 50.0, center.dy);
 
@@ -794,7 +794,7 @@
 
   testWidgets('Initial time is the default', (WidgetTester tester) async {
     late TimeOfDay result;
-    await startPicker(tester, (TimeOfDay time) { result = time; }, entryMode: TimePickerEntryMode.input);
+    await startPicker(tester, (TimeOfDay? time) { result = time!; }, entryMode: TimePickerEntryMode.input);
     await finishPicker(tester);
     expect(result, equals(const TimeOfDay(hour: 7, minute: 0)));
   });
@@ -898,7 +898,7 @@
 
   testWidgets('Entered text returns time', (WidgetTester tester) async {
     late TimeOfDay result;
-    await startPicker(tester, (TimeOfDay time) { result = time; }, entryMode: TimePickerEntryMode.input);
+    await startPicker(tester, (TimeOfDay? time) { result = time!; }, entryMode: TimePickerEntryMode.input);
     await tester.enterText(find.byType(TextField).first, '9');
     await tester.enterText(find.byType(TextField).last, '12');
     await finishPicker(tester);
@@ -907,7 +907,7 @@
 
   testWidgets('Toggle to dial mode keeps selected time', (WidgetTester tester) async {
     late TimeOfDay result;
-    await startPicker(tester, (TimeOfDay time) { result = time; }, entryMode: TimePickerEntryMode.input);
+    await startPicker(tester, (TimeOfDay? time) { result = time!; }, entryMode: TimePickerEntryMode.input);
     await tester.enterText(find.byType(TextField).first, '8');
     await tester.enterText(find.byType(TextField).last, '15');
     await tester.tap(find.byIcon(Icons.access_time));
@@ -917,7 +917,7 @@
 
   testWidgets('Invalid text prevents dismissing', (WidgetTester tester) async {
     TimeOfDay? result;
-    await startPicker(tester, (TimeOfDay time) { result = time; }, entryMode: TimePickerEntryMode.input);
+    await startPicker(tester, (TimeOfDay? time) { result = time; }, entryMode: TimePickerEntryMode.input);
 
     // Invalid hour.
     await tester.enterText(find.byType(TextField).first, '88');
@@ -939,7 +939,7 @@
 
   // Fixes regression that was reverted in https://github.com/flutter/flutter/pull/64094#pullrequestreview-469836378.
   testWidgets('Ensure hour/minute fields are top-aligned with the separator', (WidgetTester tester) async {
-    await startPicker(tester, (TimeOfDay time) { }, entryMode: TimePickerEntryMode.input);
+    await startPicker(tester, (TimeOfDay? time) { }, entryMode: TimePickerEntryMode.input);
     final double hourFieldTop = tester.getTopLeft(find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_HourTextField')).dy;
     final double minuteFieldTop = tester.getTopLeft(find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_MinuteTextField')).dy;
     final double separatorTop = tester.getTopLeft(find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_StringFragment')).dy;
diff --git a/packages/flutter/test/material/will_pop_test.dart b/packages/flutter/test/material/will_pop_test.dart
index c1c05a1..9ff3c72 100644
--- a/packages/flutter/test/material/will_pop_test.dart
+++ b/packages/flutter/test/material/will_pop_test.dart
@@ -222,8 +222,8 @@
   });
 
   testWidgets('Form.willPop callbacks do not accumulate', (WidgetTester tester) async {
-    Future<bool> showYesNoAlert(BuildContext context) {
-      return showDialog<bool>(
+    Future<bool> showYesNoAlert(BuildContext context) async {
+      return (await showDialog<bool>(
         context: context,
         builder: (BuildContext context) {
           return AlertDialog(
@@ -239,7 +239,7 @@
             ],
           );
         },
-      );
+      ))!;
     }
 
     Widget buildFrame() {
diff --git a/packages/flutter/test/rendering/mock_canvas.dart b/packages/flutter/test/rendering/mock_canvas.dart
index dceae4b..c5165c7 100644
--- a/packages/flutter/test/rendering/mock_canvas.dart
+++ b/packages/flutter/test/rendering/mock_canvas.dart
@@ -823,7 +823,6 @@
       while (predicate.moveNext()) {
         predicate.current.match(call);
       }
-      assert(predicate.current == null);
       // We allow painting more than expected.
     } on _MismatchedCall catch (data) {
       description.writeln(data.message);
diff --git a/packages/flutter/test/services/fake_platform_views.dart b/packages/flutter/test/services/fake_platform_views.dart
index c105787..e91c93d 100644
--- a/packages/flutter/test/services/fake_platform_views.dart
+++ b/packages/flutter/test/services/fake_platform_views.dart
@@ -174,11 +174,11 @@
     final Map<dynamic, dynamic> args = call.arguments as Map<dynamic, dynamic>;
     final int id = args['id'] as int;
     final String viewType = args['viewType'] as String;
-    final double width = args['width'] as double;
-    final double height = args['height'] as double;
+    final double? width = args['width'] as double?;
+    final double? height = args['height'] as double?;
     final int layoutDirection = args['direction'] as int;
-    final bool hybrid = args['hybrid'] as bool;
-    final Uint8List creationParams = args['params'] as Uint8List;
+    final bool? hybrid = args['hybrid'] as bool?;
+    final Uint8List? creationParams = args['params'] as Uint8List?;
 
     if (_views.containsKey(id))
       throw PlatformException(
@@ -197,7 +197,7 @@
     }
 
     _views[id] = FakeAndroidPlatformView(id, viewType,
-        width != null || height != null ? Size(width, height) : null,
+        width != null && height != null ? Size(width, height) : null,
         layoutDirection,
         hybrid,
         creationParams,
@@ -344,7 +344,7 @@
     final Map<dynamic, dynamic> args = call.arguments as Map<dynamic, dynamic>;
     final int id = args['id'] as int;
     final String viewType = args['viewType'] as String;
-    final Uint8List creationParams = args['params'] as Uint8List;
+    final Uint8List? creationParams = args['params'] as Uint8List?;
 
     if (_views.containsKey(id)) {
       throw PlatformException(
diff --git a/packages/flutter/test/services/platform_views_test.dart b/packages/flutter/test/services/platform_views_test.dart
index 1db8c6a..d438692 100644
--- a/packages/flutter/test/services/platform_views_test.dart
+++ b/packages/flutter/test/services/platform_views_test.dart
@@ -2,7 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-
 import 'package:flutter/painting.dart';
 import 'package:flutter/services.dart';
 import 'package:flutter_test/flutter_test.dart' show TestWidgetsFlutterBinding;
diff --git a/packages/flutter/test/widgets/custom_paint_test.dart b/packages/flutter/test/widgets/custom_paint_test.dart
index 24e2d3a..68013a3 100644
--- a/packages/flutter/test/widgets/custom_paint_test.dart
+++ b/packages/flutter/test/widgets/custom_paint_test.dart
@@ -58,7 +58,7 @@
 
 void main() {
   testWidgets('Control test for custom painting', (WidgetTester tester) async {
-    final List<String> log = <String>[];
+    final List<String?> log = <String?>[];
     await tester.pumpWidget(CustomPaint(
       painter: TestCustomPainter(
         log: log,
@@ -82,7 +82,7 @@
   testWidgets('Throws FlutterError on custom painter incorrect restore/save calls', (
       WidgetTester tester) async {
     final GlobalKey target = GlobalKey();
-    final List<String> log = <String>[];
+    final List<String?> log = <String?>[];
     await tester.pumpWidget(CustomPaint(
       key: target,
       isComplex: true,
@@ -174,7 +174,7 @@
   testWidgets('Raster cache hints', (WidgetTester tester) async {
     final GlobalKey target = GlobalKey();
 
-    final List<String> log = <String>[];
+    final List<String?> log = <String?>[];
     await tester.pumpWidget(CustomPaint(
       key: target,
       isComplex: true,
diff --git a/packages/flutter/test/widgets/dismissible_test.dart b/packages/flutter/test/widgets/dismissible_test.dart
index 1589ad9..1ac1732 100644
--- a/packages/flutter/test/widgets/dismissible_test.dart
+++ b/packages/flutter/test/widgets/dismissible_test.dart
@@ -18,7 +18,7 @@
 Widget buildTest({
   double? startToEndThreshold,
   TextDirection textDirection = TextDirection.ltr,
-  Future<bool> Function(BuildContext context, DismissDirection direction)? confirmDismiss,
+  Future<bool?> Function(BuildContext context, DismissDirection direction)? confirmDismiss,
 }) {
   return Directionality(
     textDirection: textDirection,
@@ -679,7 +679,7 @@
       return buildTest(
         confirmDismiss: (BuildContext context, DismissDirection dismissDirection) {
           confirmDismissDirection = dismissDirection;
-          return Future<bool>.value(confirmDismissValue);
+          return Future<bool?>.value(confirmDismissValue);
         }
       );
     }
diff --git a/packages/flutter/test/widgets/image_test.dart b/packages/flutter/test/widgets/image_test.dart
index b45b963..1046e02 100644
--- a/packages/flutter/test/widgets/image_test.dart
+++ b/packages/flutter/test/widgets/image_test.dart
@@ -1516,7 +1516,7 @@
     expect(imageCache!.liveImageCount, 1);
     expect(imageCache!.containsKey(provider), false);
 
-    final ImageCacheStatus providerLocation = await provider.obtainCacheStatus(configuration: ImageConfiguration.empty);
+    final ImageCacheStatus providerLocation = (await provider.obtainCacheStatus(configuration: ImageConfiguration.empty))!;
 
     expect(providerLocation, isNotNull);
     expect(providerLocation.live, true);
diff --git a/packages/flutter/test/widgets/navigator_test.dart b/packages/flutter/test/widgets/navigator_test.dart
index d0de31e..a08d14b 100644
--- a/packages/flutter/test/widgets/navigator_test.dart
+++ b/packages/flutter/test/widgets/navigator_test.dart
@@ -957,7 +957,7 @@
   });
 
   testWidgets('replaceNamed returned value', (WidgetTester tester) async {
-    late Future<String> value;
+    late Future<String?> value;
 
     final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
       '/' : (BuildContext context) => OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }),
@@ -1001,7 +1001,7 @@
     expect(find.text('A'), findsNothing);
     expect(find.text('B'), findsNothing);
 
-    final String replaceNamedValue = await value; // replaceNamed result was 'B'
+    final String? replaceNamedValue = await value; // replaceNamed result was 'B'
     expect(replaceNamedValue, 'B');
   });
 
@@ -1092,7 +1092,7 @@
   });
 
   testWidgets('remove a route whose value is awaited', (WidgetTester tester) async {
-    late Future<String> pageValue;
+    late Future<String?> pageValue;
     final Map<String, WidgetBuilder> pageBuilders = <String, WidgetBuilder>{
       '/':  (BuildContext context) => OnTapPage(id: '/', onTap: () { pageValue = Navigator.pushNamed(context, '/A'); }),
       '/A': (BuildContext context) => OnTapPage(id: 'A', onTap: () { Navigator.pop(context, 'A'); }),
@@ -1113,7 +1113,7 @@
 
     await tester.tap(find.text('/')); // pushNamed('/A'), stack becomes /, /A
     await tester.pumpAndSettle();
-    pageValue.then((String value) { assert(false); });
+    pageValue.then((String? value) { assert(false); });
 
     final NavigatorState navigator = tester.state<NavigatorState>(find.byType(Navigator));
     navigator.removeRoute(routes['/A']!); // stack becomes /, pageValue will not complete
diff --git a/packages/flutter/test/widgets/restorable_property_test.dart b/packages/flutter/test/widgets/restorable_property_test.dart
index fa63962..85a10de 100644
--- a/packages/flutter/test/widgets/restorable_property_test.dart
+++ b/packages/flutter/test/widgets/restorable_property_test.dart
@@ -285,7 +285,7 @@
   });
 }
 
-class _TestRestorableValue extends RestorableValue<Object> {
+class _TestRestorableValue extends RestorableValue<Object?> {
   @override
   Object createDefaultValue() {
     return 55;
@@ -300,12 +300,12 @@
   }
 
   @override
-  Object fromPrimitives(Object data) {
+  Object? fromPrimitives(Object? data) {
     return data;
   }
 
   @override
-  Object toPrimitives() {
+  Object? toPrimitives() {
     return value;
   }
 }
diff --git a/packages/flutter/test/widgets/restoration_mixin_test.dart b/packages/flutter/test/widgets/restoration_mixin_test.dart
index 8e0ff5d..f44348d 100644
--- a/packages/flutter/test/widgets/restoration_mixin_test.dart
+++ b/packages/flutter/test/widgets/restoration_mixin_test.dart
@@ -632,7 +632,7 @@
   });
 
   test('RestorableProperty throws after disposed', () {
-    final RestorableProperty<Object> property = _TestRestorableProperty(10);
+    final RestorableProperty<Object?> property = _TestRestorableProperty(10);
     property.dispose();
     expect(() => property.dispose(), throwsFlutterError);
   });
@@ -660,8 +660,8 @@
   _TestRestorableProperty? additionalProperty;
   bool _rerigisterAdditionalProperty = false;
 
-  final List<RestorationBucket?> restoreStateLog = <RestorationBucket>[];
-  final List<RestorationBucket?> toggleBucketLog = <RestorationBucket>[];
+  final List<RestorationBucket?> restoreStateLog = <RestorationBucket?>[];
+  final List<RestorationBucket?> toggleBucketLog = <RestorationBucket?>[];
 
   @override
   void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
@@ -737,7 +737,7 @@
   };
 }
 
-class _TestRestorableProperty extends RestorableProperty<Object> {
+class _TestRestorableProperty extends RestorableProperty<Object?> {
   _TestRestorableProperty(this._value);
 
   List<String> log = <String>[];
@@ -751,35 +751,35 @@
   }
 
   @override
-  Object createDefaultValue() {
+  Object? createDefaultValue() {
     log.add('createDefaultValue');
     return _value;
   }
 
   @override
-  Object fromPrimitives(Object data) {
+  Object? fromPrimitives(Object? data) {
     log.add('fromPrimitives');
     return data;
   }
 
-  Object get value {
+  Object? get value {
     assert(isRegistered);
     return _value;
   }
-  Object _value;
-  set value(Object value) {
+  Object? _value;
+  set value(Object? value) {
     _value = value;
     notifyListeners();
   }
 
   @override
-  void initWithValue(Object v) {
+  void initWithValue(Object? v) {
     log.add('initWithValue');
     _value = v;
   }
 
   @override
-  Object toPrimitives() {
+  Object? toPrimitives() {
     log.add('toPrimitives');
     return _value;
   }
diff --git a/packages/flutter/test/widgets/restoration_scopes_moving_test.dart b/packages/flutter/test/widgets/restoration_scopes_moving_test.dart
index 3c07df3..cac9033 100644
--- a/packages/flutter/test/widgets/restoration_scopes_moving_test.dart
+++ b/packages/flutter/test/widgets/restoration_scopes_moving_test.dart
@@ -209,7 +209,7 @@
 }
 
 class TestWidgetState extends State<TestWidget> with RestorationMixin {
-  List<RestorationBucket?> buckets = <RestorationBucket>[];
+  List<RestorationBucket?> buckets = <RestorationBucket?>[];
   List<bool> flags = <bool>[];
 
   @override
diff --git a/packages/flutter/test/widgets/root_restoration_scope_test.dart b/packages/flutter/test/widgets/root_restoration_scope_test.dart
index 85d57ce..4a09020 100644
--- a/packages/flutter/test/widgets/root_restoration_scope_test.dart
+++ b/packages/flutter/test/widgets/root_restoration_scope_test.dart
@@ -302,7 +302,7 @@
   });
 
   testWidgets('injects null when rootBucket is null', (WidgetTester tester) async {
-    final Completer<RestorationBucket> completer = Completer<RestorationBucket>();
+    final Completer<RestorationBucket?> completer = Completer<RestorationBucket?>();
     binding.restorationManager.rootBucket = completer.future;
 
     await tester.pumpWidget(
diff --git a/packages/flutter/test/widgets/routes_test.dart b/packages/flutter/test/widgets/routes_test.dart
index 2fd08a3..b5fdfb8 100644
--- a/packages/flutter/test/widgets/routes_test.dart
+++ b/packages/flutter/test/widgets/routes_test.dart
@@ -1319,28 +1319,28 @@
       final Finder animatedModalBarrier = find.byType(AnimatedModalBarrier);
       expect(animatedModalBarrier, findsOneWidget);
 
-      Animation<Color> modalBarrierAnimation;
+      Animation<Color?> modalBarrierAnimation;
       modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
       expect(modalBarrierAnimation.value, Colors.transparent);
 
       await tester.pump(const Duration(milliseconds: 25));
       modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
       expect(
-        modalBarrierAnimation.value.alpha,
+        modalBarrierAnimation.value!.alpha,
         closeTo(_getExpectedBarrierTweenAlphaValue(0.25), 1),
       );
 
       await tester.pump(const Duration(milliseconds: 25));
       modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
       expect(
-        modalBarrierAnimation.value.alpha,
+        modalBarrierAnimation.value!.alpha,
         closeTo(_getExpectedBarrierTweenAlphaValue(0.50), 1),
       );
 
       await tester.pump(const Duration(milliseconds: 25));
       modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
       expect(
-        modalBarrierAnimation.value.alpha,
+        modalBarrierAnimation.value!.alpha,
         closeTo(_getExpectedBarrierTweenAlphaValue(0.75), 1),
       );
 
@@ -1382,28 +1382,28 @@
       final Finder animatedModalBarrier = find.byType(AnimatedModalBarrier);
       expect(animatedModalBarrier, findsOneWidget);
 
-      Animation<Color> modalBarrierAnimation;
+      Animation<Color?> modalBarrierAnimation;
       modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
       expect(modalBarrierAnimation.value, Colors.transparent);
 
       await tester.pump(const Duration(milliseconds: 25));
       modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
       expect(
-        modalBarrierAnimation.value.alpha,
+        modalBarrierAnimation.value!.alpha,
         closeTo(_getExpectedBarrierTweenAlphaValue(0.25), 1),
       );
 
       await tester.pump(const Duration(milliseconds: 25));
       modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
       expect(
-        modalBarrierAnimation.value.alpha,
+        modalBarrierAnimation.value!.alpha,
         closeTo(_getExpectedBarrierTweenAlphaValue(0.50), 1),
       );
 
       await tester.pump(const Duration(milliseconds: 25));
       modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
       expect(
-        modalBarrierAnimation.value.alpha,
+        modalBarrierAnimation.value!.alpha,
         closeTo(_getExpectedBarrierTweenAlphaValue(0.75), 1),
       );
 
diff --git a/packages/flutter_test/lib/src/_matchers_io.dart b/packages/flutter_test/lib/src/_matchers_io.dart
index 9c1f022..80d6919 100644
--- a/packages/flutter_test/lib/src/_matchers_io.dart
+++ b/packages/flutter_test/lib/src/_matchers_io.dart
@@ -49,27 +49,31 @@
 
   @override
   Future<String?> matchAsync(dynamic item) async {
-    Future<ui.Image> imageFuture;
-    if (item is Future<ui.Image>) {
+    Future<ui.Image?> imageFuture;
+    if (item is Future<ui.Image?>) {
       imageFuture = item;
     } else if (item is ui.Image) {
       imageFuture = Future<ui.Image>.value(item);
-    } else {
-      final Finder finder = item as Finder;
-      final Iterable<Element> elements = finder.evaluate();
+    } else if (item is Finder) {
+      final Iterable<Element> elements = item.evaluate();
       if (elements.isEmpty) {
         return 'could not be rendered because no widget was found';
       } else if (elements.length > 1) {
         return 'matched too many widgets';
       }
       imageFuture = captureImage(elements.single);
+    } else {
+      throw 'must provide a Finder, Image, or Future<Image>';
     }
 
     final Uri testNameUri = goldenFileComparator.getTestUri(key, version);
 
     final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
     return binding.runAsync<String?>(() async {
-      final ui.Image image = await imageFuture;
+      final ui.Image? image = await imageFuture;
+      if (image == null) {
+        throw 'Future<Image> completed to null';
+      }
       final ByteData? bytes = await image.toByteData(format: ui.ImageByteFormat.png);
       if (bytes == null)
         return 'could not encode screenshot.';
diff --git a/packages/flutter_test/lib/src/binding.dart b/packages/flutter_test/lib/src/binding.dart
index 0b76a0b..116746a 100644
--- a/packages/flutter_test/lib/src/binding.dart
+++ b/packages/flutter_test/lib/src/binding.dart
@@ -1011,17 +1011,19 @@
 
     addTime(additionalTime);
 
-    return realAsyncZone.run<Future<T>>(() {
+    return realAsyncZone.run<Future<T?>>(() async {
       _pendingAsyncTasks = Completer<void>();
-      return callback().catchError((Object exception, StackTrace stack) {
+      T? result;
+      try {
+        result = await callback();
+      } catch (exception, stack) {
         FlutterError.reportError(FlutterErrorDetails(
           exception: exception,
           stack: stack,
           library: 'Flutter test framework',
           context: ErrorDescription('while running async test code'),
         ));
-        return null;
-      }).whenComplete(() {
+      } finally {
         // We complete the _pendingAsyncTasks future successfully regardless of
         // whether an exception occurred because in the case of an exception,
         // we already reported the exception to FlutterError. Moreover,
@@ -1029,7 +1031,8 @@
         // exception due to zone error boundaries.
         _pendingAsyncTasks!.complete();
         _pendingAsyncTasks = null;
-      });
+      }
+      return result;
     });
   }
 
diff --git a/packages/flutter_test/test/test_config/config_test_utils.dart b/packages/flutter_test/test/test_config/config_test_utils.dart
index 6c17239..d86cf7b 100644
--- a/packages/flutter_test/test/test_config/config_test_utils.dart
+++ b/packages/flutter_test/test/test_config/config_test_utils.dart
@@ -11,7 +11,7 @@
   String? expectedStringValue, {
   Map<Type, dynamic> otherExpectedValues = const <Type, dynamic>{int: isNull},
 }) {
-  final String actualStringValue = Zone.current[String] as String;
+  final String? actualStringValue = Zone.current[String] as String?;
   final Map<Type, dynamic> otherActualValues = otherExpectedValues.map<Type, dynamic>(
     (Type key, dynamic value) {
       return MapEntry<Type, dynamic>(key, Zone.current[key]);