Unverified Commit 42f3709a authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Sound null safety for framework and flutter_test (#68642)

parent 955e0746
...@@ -528,7 +528,8 @@ Future<void> _runAddToAppLifeCycleTests() async { ...@@ -528,7 +528,8 @@ Future<void> _runAddToAppLifeCycleTests() async {
Future<void> _runFrameworkTests() async { Future<void> _runFrameworkTests() async {
final bq.BigqueryApi bigqueryApi = await _getBigqueryApi(); 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']; final List<String> trackWidgetCreationAlternatives = <String>['--track-widget-creation', '--no-track-widget-creation'];
Future<void> runWidgets() async { Future<void> runWidgets() async {
...@@ -536,7 +537,7 @@ Future<void> _runFrameworkTests() async { ...@@ -536,7 +537,7 @@ Future<void> _runFrameworkTests() async {
for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) { for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) {
await _runFlutterTest( await _runFlutterTest(
path.join(flutterRoot, 'packages', 'flutter'), path.join(flutterRoot, 'packages', 'flutter'),
options: <String>[trackWidgetCreationOption, ...nullSafetyOptions], options: <String>[trackWidgetCreationOption, ...soundNullSafetyOptions],
tableData: bigqueryApi?.tabledata, tableData: bigqueryApi?.tabledata,
tests: <String>[ path.join('test', 'widgets') + path.separator ], tests: <String>[ path.join('test', 'widgets') + path.separator ],
); );
...@@ -562,7 +563,7 @@ Future<void> _runFrameworkTests() async { ...@@ -562,7 +563,7 @@ Future<void> _runFrameworkTests() async {
for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) { for (final String trackWidgetCreationOption in trackWidgetCreationAlternatives) {
await _runFlutterTest( await _runFlutterTest(
path.join(flutterRoot, 'packages', 'flutter'), path.join(flutterRoot, 'packages', 'flutter'),
options: <String>[trackWidgetCreationOption, ...nullSafetyOptions], options: <String>[trackWidgetCreationOption, ...soundNullSafetyOptions],
tableData: bigqueryApi?.tabledata, tableData: bigqueryApi?.tabledata,
tests: tests, tests: tests,
); );
...@@ -613,14 +614,14 @@ Future<void> _runFrameworkTests() async { ...@@ -613,14 +614,14 @@ Future<void> _runFrameworkTests() async {
await _runFlutterTest(path.join(flutterRoot, 'dev', 'manual_tests'), tableData: bigqueryApi?.tabledata); 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, 'dev', 'tools', 'vitool'), tableData: bigqueryApi?.tabledata);
await _runFlutterTest(path.join(flutterRoot, 'examples', 'hello_world'), 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, '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_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_goldens'), tableData: bigqueryApi?.tabledata);
await _runFlutterTest(path.join(flutterRoot, 'packages', 'flutter_localizations'), 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, '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( await _runFlutterTest(
path.join(flutterRoot, 'dev', 'tracing_tests'), path.join(flutterRoot, 'dev', 'tracing_tests'),
options: <String>['--enable-vmservice'], options: <String>['--enable-vmservice'],
......
# 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.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // 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 // 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. // system. Most of the guts of this examples are in src/sector_layout.dart.
......
...@@ -731,7 +731,7 @@ class _ContextMenuRoute<T> extends PopupRoute<T> { ...@@ -731,7 +731,7 @@ class _ContextMenuRoute<T> extends PopupRoute<T> {
} }
@override @override
bool didPop(T result) { bool didPop(T? result) {
_updateTweenRects(); _updateTweenRects();
return super.didPop(result); return super.didPop(result);
} }
......
...@@ -1049,7 +1049,7 @@ class _CupertinoModalPopupRoute<T> extends PopupRoute<T> { ...@@ -1049,7 +1049,7 @@ class _CupertinoModalPopupRoute<T> extends PopupRoute<T> {
/// * [CupertinoActionSheet], which is the widget usually returned by the /// * [CupertinoActionSheet], which is the widget usually returned by the
/// `builder` argument to [showCupertinoModalPopup]. /// `builder` argument to [showCupertinoModalPopup].
/// * <https://developer.apple.com/design/human-interface-guidelines/ios/views/action-sheets/> /// * <https://developer.apple.com/design/human-interface-guidelines/ios/views/action-sheets/>
Future<T> showCupertinoModalPopup<T>({ Future<T?> showCupertinoModalPopup<T>({
required BuildContext context, required BuildContext context,
required WidgetBuilder builder, required WidgetBuilder builder,
ImageFilter? filter, ImageFilter? filter,
...@@ -1134,7 +1134,7 @@ Widget _buildCupertinoDialogTransitions(BuildContext context, Animation<double> ...@@ -1134,7 +1134,7 @@ Widget _buildCupertinoDialogTransitions(BuildContext context, Animation<double>
/// * [showDialog], which displays a Material-style dialog. /// * [showDialog], which displays a Material-style dialog.
/// * [showGeneralDialog], which allows for customization of the dialog popup. /// * [showGeneralDialog], which allows for customization of the dialog popup.
/// * <https://developer.apple.com/ios/human-interface-guidelines/views/alerts/> /// * <https://developer.apple.com/ios/human-interface-guidelines/views/alerts/>
Future<T> showCupertinoDialog<T>({ Future<T?> showCupertinoDialog<T>({
required BuildContext context, required BuildContext context,
required WidgetBuilder builder, required WidgetBuilder builder,
bool useRootNavigator = true, bool useRootNavigator = true,
......
...@@ -619,8 +619,9 @@ class RestorableCupertinoTabController extends RestorableChangeNotifier<Cupertin ...@@ -619,8 +619,9 @@ class RestorableCupertinoTabController extends RestorableChangeNotifier<Cupertin
} }
@override @override
CupertinoTabController fromPrimitives(Object data) { CupertinoTabController fromPrimitives(Object? data) {
return CupertinoTabController(initialIndex: data as int); assert(data != null);
return CupertinoTabController(initialIndex: data! as int);
} }
@override @override
......
...@@ -781,7 +781,7 @@ class _CupertinoTextSelectionToolbarItemsElement extends RenderObjectElement { ...@@ -781,7 +781,7 @@ class _CupertinoTextSelectionToolbarItemsElement extends RenderObjectElement {
} }
if (slot is IndexedSlot) { if (slot is IndexedSlot) {
assert(renderObject.debugValidateChild(child)); 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; return;
} }
assert(false, 'slot must be _CupertinoTextSelectionToolbarItemsSlot or IndexedSlot'); assert(false, 'slot must be _CupertinoTextSelectionToolbarItemsSlot or IndexedSlot');
......
...@@ -166,7 +166,7 @@ void mergeSort<T>( ...@@ -166,7 +166,7 @@ void mergeSort<T>(
final int firstLength = middle - start; final int firstLength = middle - start;
final int secondLength = end - middle; final int secondLength = end - middle;
// secondLength is always the same as firstLength, or one greater. // 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); _mergeSort<T>(list, compare, middle, end, scratchSpace, 0);
final int firstTarget = end - firstLength; final int firstTarget = end - firstLength;
_mergeSort<T>(list, compare, start, middle, list, firstTarget); _mergeSort<T>(list, compare, start, middle, list, firstTarget);
...@@ -273,7 +273,7 @@ void _mergeSort<T>( ...@@ -273,7 +273,7 @@ void _mergeSort<T>(
int Function(T, T) compare, int Function(T, T) compare,
int start, int start,
int end, int end,
List<T?> target, List<T> target,
int targetOffset, int targetOffset,
) { ) {
final int length = end - start; final int length = end - start;
...@@ -316,10 +316,10 @@ void _merge<T>( ...@@ -316,10 +316,10 @@ void _merge<T>(
List<T> firstList, List<T> firstList,
int firstStart, int firstStart,
int firstEnd, int firstEnd,
List<T?> secondList, List<T> secondList,
int secondStart, int secondStart,
int secondEnd, int secondEnd,
List<T?> target, List<T> target,
int targetOffset, int targetOffset,
) { ) {
// No empty lists reaches here. // No empty lists reaches here.
...@@ -328,7 +328,7 @@ void _merge<T>( ...@@ -328,7 +328,7 @@ void _merge<T>(
int cursor1 = firstStart; int cursor1 = firstStart;
int cursor2 = secondStart; int cursor2 = secondStart;
T firstElement = firstList[cursor1++]; T firstElement = firstList[cursor1++];
T secondElement = secondList[cursor2++] as T; T secondElement = secondList[cursor2++];
while (true) { while (true) {
if (compare(firstElement, secondElement) <= 0) { if (compare(firstElement, secondElement) <= 0) {
target[targetOffset++] = firstElement; target[targetOffset++] = firstElement;
...@@ -340,7 +340,7 @@ void _merge<T>( ...@@ -340,7 +340,7 @@ void _merge<T>(
} else { } else {
target[targetOffset++] = secondElement; target[targetOffset++] = secondElement;
if (cursor2 != secondEnd) { if (cursor2 != secondEnd) {
secondElement = secondList[cursor2++] as T; secondElement = secondList[cursor2++];
continue; continue;
} }
// Second list empties first. Flushing first list here. // Second list empties first. Flushing first list here.
......
...@@ -644,7 +644,7 @@ class _BottomSheetSuspendedCurve extends ParametricCurve<double> { ...@@ -644,7 +644,7 @@ class _BottomSheetSuspendedCurve extends ParametricCurve<double> {
/// * [DraggableScrollableSheet], which allows you to create a bottom sheet /// * [DraggableScrollableSheet], which allows you to create a bottom sheet
/// that grows and then becomes scrollable once it reaches its maximum size. /// that grows and then becomes scrollable once it reaches its maximum size.
/// * <https://material.io/design/components/sheets-bottom.html#modal-bottom-sheet> /// * <https://material.io/design/components/sheets-bottom.html#modal-bottom-sheet>
Future<T> showModalBottomSheet<T>({ Future<T?> showModalBottomSheet<T>({
required BuildContext context, required BuildContext context,
required WidgetBuilder builder, required WidgetBuilder builder,
Color? backgroundColor, Color? backgroundColor,
......
...@@ -955,7 +955,7 @@ Widget _buildMaterialDialogTransitions(BuildContext context, Animation<double> a ...@@ -955,7 +955,7 @@ Widget _buildMaterialDialogTransitions(BuildContext context, Animation<double> a
/// * [showCupertinoDialog], which displays an iOS-style dialog. /// * [showCupertinoDialog], which displays an iOS-style dialog.
/// * [showGeneralDialog], which allows for customization of the dialog popup. /// * [showGeneralDialog], which allows for customization of the dialog popup.
/// * <https://material.io/design/components/dialogs.html> /// * <https://material.io/design/components/dialogs.html>
Future<T> showDialog<T>({ Future<T?> showDialog<T>({
required BuildContext context, required BuildContext context,
WidgetBuilder? builder, WidgetBuilder? builder,
bool barrierDismissible = true, bool barrierDismissible = true,
......
...@@ -120,7 +120,7 @@ typedef MaterialPropertyResolver<T> = T Function(Set<MaterialState> states); ...@@ -120,7 +120,7 @@ typedef MaterialPropertyResolver<T> = T Function(Set<MaterialState> states);
/// } /// }
/// ``` /// ```
/// {@end-tool} /// {@end-tool}
abstract class MaterialStateColor extends Color implements MaterialStateProperty<Color?> { abstract class MaterialStateColor extends Color implements MaterialStateProperty<Color> {
/// Creates a [MaterialStateColor]. /// Creates a [MaterialStateColor].
const MaterialStateColor(int defaultValue) : super(defaultValue); const MaterialStateColor(int defaultValue) : super(defaultValue);
......
...@@ -99,7 +99,7 @@ const double _inputFormLandscapeHeight = 108.0; ...@@ -99,7 +99,7 @@ const double _inputFormLandscapeHeight = 108.0;
/// * [CalendarDatePicker], which provides the calendar grid used by the date picker dialog. /// * [CalendarDatePicker], which provides the calendar grid used by the date picker dialog.
/// * [InputDatePickerFormField], which provides a text input field for entering dates. /// * [InputDatePickerFormField], which provides a text input field for entering dates.
/// ///
Future<DateTime> showDatePicker({ Future<DateTime?> showDatePicker({
required BuildContext context, required BuildContext context,
required DateTime initialDate, required DateTime initialDate,
required DateTime firstDate, required DateTime firstDate,
......
...@@ -105,7 +105,7 @@ const double _inputFormLandscapeHeight = 108.0; ...@@ -105,7 +105,7 @@ const double _inputFormLandscapeHeight = 108.0;
/// select a single date. /// select a single date.
/// * [DateTimeRange], which is used to describe a date range. /// * [DateTimeRange], which is used to describe a date range.
/// ///
Future<DateTimeRange> showDateRangePicker({ Future<DateTimeRange?> showDateRangePicker({
required BuildContext context, required BuildContext context,
DateTimeRange? initialDateRange, DateTimeRange? initialDateRange,
required DateTime firstDate, required DateTime firstDate,
......
...@@ -829,7 +829,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> { ...@@ -829,7 +829,7 @@ class _PopupMenuRoute<T> extends PopupRoute<T> {
/// calling this method automatically. /// calling this method automatically.
/// * [SemanticsConfiguration.namesRoute], for a description of edge triggered /// * [SemanticsConfiguration.namesRoute], for a description of edge triggered
/// semantics. /// semantics.
Future<T> showMenu<T>({ Future<T?> showMenu<T>({
required BuildContext context, required BuildContext context,
required RelativeRect position, required RelativeRect position,
required List<PopupMenuEntry<T>> items, required List<PopupMenuEntry<T>> items,
...@@ -1088,7 +1088,7 @@ class PopupMenuButtonState<T> extends State<PopupMenuButton<T>> { ...@@ -1088,7 +1088,7 @@ class PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
final List<PopupMenuEntry<T>> items = widget.itemBuilder(context); final List<PopupMenuEntry<T>> items = widget.itemBuilder(context);
// Only show the menu if there is something to show // Only show the menu if there is something to show
if (items.isNotEmpty) { if (items.isNotEmpty) {
showMenu<T>( showMenu<T?>(
context: context, context: context,
elevation: widget.elevation ?? popupMenuTheme.elevation, elevation: widget.elevation ?? popupMenuTheme.elevation,
items: items, items: items,
...@@ -1098,7 +1098,7 @@ class PopupMenuButtonState<T> extends State<PopupMenuButton<T>> { ...@@ -1098,7 +1098,7 @@ class PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
color: widget.color ?? popupMenuTheme.color, color: widget.color ?? popupMenuTheme.color,
captureInheritedThemes: widget.captureInheritedThemes, captureInheritedThemes: widget.captureInheritedThemes,
) )
.then<void>((T newValue) { .then<void>((T? newValue) {
if (!mounted) if (!mounted)
return null; return null;
if (newValue == null) { if (newValue == null) {
......
...@@ -49,7 +49,7 @@ import 'theme.dart'; ...@@ -49,7 +49,7 @@ import 'theme.dart';
/// See also: /// See also:
/// ///
/// * [SearchDelegate] to define the content of the search page. /// * [SearchDelegate] to define the content of the search page.
Future<T> showSearch<T>({ Future<T?> showSearch<T>({
required BuildContext context, required BuildContext context,
required SearchDelegate<T> delegate, required SearchDelegate<T> delegate,
String? query = '', String? query = '',
...@@ -387,7 +387,7 @@ class _SearchPageRoute<T> extends PageRoute<T> { ...@@ -387,7 +387,7 @@ class _SearchPageRoute<T> extends PageRoute<T> {
} }
@override @override
void didComplete(T result) { void didComplete(T? result) {
super.didComplete(result); super.didComplete(result);
assert(delegate._route == this); assert(delegate._route == this);
delegate._route = null; delegate._route = null;
......
...@@ -2175,7 +2175,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { ...@@ -2175,7 +2175,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> {
/// date picker. /// date picker.
/// * [TimePickerThemeData], which allows you to customize the colors, /// * [TimePickerThemeData], which allows you to customize the colors,
/// typography, and shape of the time picker. /// typography, and shape of the time picker.
Future<TimeOfDay> showTimePicker({ Future<TimeOfDay?> showTimePicker({
required BuildContext context, required BuildContext context,
required TimeOfDay initialTime, required TimeOfDay initialTime,
TransitionBuilder? builder, TransitionBuilder? builder,
......
...@@ -379,12 +379,12 @@ abstract class ImageProvider<T extends Object> { ...@@ -379,12 +379,12 @@ abstract class ImageProvider<T extends Object> {
/// [FlutterError.onError], and the method will return null. /// [FlutterError.onError], and the method will return null.
/// ///
/// A completed return value of null indicates that an error has occurred. /// A completed return value of null indicates that an error has occurred.
Future<ImageCacheStatus> obtainCacheStatus({ Future<ImageCacheStatus?> obtainCacheStatus({
required ImageConfiguration configuration, required ImageConfiguration configuration,
ImageErrorListener? handleError, ImageErrorListener? handleError,
}) { }) {
assert(configuration != null); assert(configuration != null);
final Completer<ImageCacheStatus> completer = Completer<ImageCacheStatus>(); final Completer<ImageCacheStatus?> completer = Completer<ImageCacheStatus?>();
_createErrorHandlerAndKey( _createErrorHandlerAndKey(
configuration, configuration,
(T key, ImageErrorListener innerHandleError) { (T key, ImageErrorListener innerHandleError) {
......
...@@ -390,7 +390,7 @@ class RenderTable extends RenderBox { ...@@ -390,7 +390,7 @@ class RenderTable extends RenderBox {
_textBaseline = textBaseline, _textBaseline = textBaseline,
_defaultVerticalAlignment = defaultVerticalAlignment, _defaultVerticalAlignment = defaultVerticalAlignment,
_configuration = configuration { _configuration = configuration {
_children = <RenderBox>[]..length = _columns * _rows; _children = <RenderBox?>[]..length = _columns * _rows;
this.rowDecorations = rowDecorations; // must use setter to initialize box painters array this.rowDecorations = rowDecorations; // must use setter to initialize box painters array
children?.forEach(addRow); children?.forEach(addRow);
} }
...@@ -645,7 +645,7 @@ class RenderTable extends RenderBox { ...@@ -645,7 +645,7 @@ class RenderTable extends RenderBox {
// update our internal values // update our internal values
_columns = columns; _columns = columns;
_rows = cells.length ~/ columns; _rows = cells.length ~/ columns;
_children = cells.toList(); _children = List<RenderBox?>.from(cells);
assert(_children.length == rows * columns); assert(_children.length == rows * columns);
markNeedsLayout(); markNeedsLayout();
} }
......
...@@ -151,13 +151,13 @@ class RestorationManager extends ChangeNotifier { ...@@ -151,13 +151,13 @@ class RestorationManager extends ChangeNotifier {
return SynchronousFuture<RestorationBucket?>(_rootBucket); return SynchronousFuture<RestorationBucket?>(_rootBucket);
} }
if (_pendingRootBucket == null) { if (_pendingRootBucket == null) {
_pendingRootBucket = Completer<RestorationBucket>(); _pendingRootBucket = Completer<RestorationBucket?>();
_getRootBucketFromEngine(); _getRootBucketFromEngine();
} }
return _pendingRootBucket!.future; return _pendingRootBucket!.future;
} }
RestorationBucket? _rootBucket; // May be null to indicate that restoration is turned off. RestorationBucket? _rootBucket; // May be null to indicate that restoration is turned off.
Completer<RestorationBucket>? _pendingRootBucket; Completer<RestorationBucket?>? _pendingRootBucket;
bool _rootBucketIsValid = false; bool _rootBucketIsValid = false;
/// Returns true for the frame after [rootBucket] has been replaced with a /// Returns true for the frame after [rootBucket] has been replaced with a
...@@ -186,7 +186,7 @@ class RestorationManager extends ChangeNotifier { ...@@ -186,7 +186,7 @@ class RestorationManager extends ChangeNotifier {
void _parseAndHandleRestorationUpdateFromEngine(Map<dynamic, dynamic>? update) { void _parseAndHandleRestorationUpdateFromEngine(Map<dynamic, dynamic>? update) {
handleRestorationUpdateFromEngine( handleRestorationUpdateFromEngine(
enabled: update != null && update['enabled'] as bool, 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 @@ class RestorationBucket { ...@@ -580,10 +580,10 @@ class RestorationBucket {
/// * [remove], which removes a value from the bucket. /// * [remove], which removes a value from the bucket.
/// * [contains], which checks whether any value is stored under a given /// * [contains], which checks whether any value is stored under a given
/// restoration ID. /// restoration ID.
P read<P>(String restorationId) { P? read<P>(String restorationId) {
assert(_debugAssertNotDisposed()); assert(_debugAssertNotDisposed());
assert(restorationId != null); assert(restorationId != null);
return _rawValues[restorationId] as P; return _rawValues[restorationId] as P?;
} }
/// Stores the provided `value` of type `P` under the provided `restorationId` /// Stores the provided `value` of type `P` under the provided `restorationId`
...@@ -624,11 +624,11 @@ class RestorationBucket { ...@@ -624,11 +624,11 @@ class RestorationBucket {
/// * [write], which stores a value in the bucket. /// * [write], which stores a value in the bucket.
/// * [contains], which checks whether any value is stored under a given /// * [contains], which checks whether any value is stored under a given
/// restoration ID. /// restoration ID.
P remove<P>(String restorationId) { P? remove<P>(String restorationId) {
assert(_debugAssertNotDisposed()); assert(_debugAssertNotDisposed());
assert(restorationId != null); assert(restorationId != null);
final bool needsUpdate = _rawValues.containsKey(restorationId); 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) { if (_rawValues.isEmpty) {
_rawData.remove(_valuesMapKey); _rawData.remove(_valuesMapKey);
} }
......
...@@ -28,7 +28,7 @@ typedef DismissDirectionCallback = void Function(DismissDirection direction); ...@@ -28,7 +28,7 @@ typedef DismissDirectionCallback = void Function(DismissDirection direction);
/// confirm or veto a dismiss gesture. /// confirm or veto a dismiss gesture.
/// ///
/// Used by [Dismissible.confirmDismiss]. /// 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. /// The direction in which a [Dismissible] can be dismissed.
enum DismissDirection { enum DismissDirection {
...@@ -120,7 +120,7 @@ class Dismissible extends StatefulWidget { ...@@ -120,7 +120,7 @@ class Dismissible extends StatefulWidget {
/// If the returned Future<bool> completes true, then this widget will be /// If the returned Future<bool> completes true, then this widget will be
/// dismissed, otherwise it will be moved back to its original location. /// 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. /// and [onDismissed] callbacks will not run.
final ConfirmDismissCallback? confirmDismiss; final ConfirmDismissCallback? confirmDismiss;
...@@ -458,7 +458,7 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin ...@@ -458,7 +458,7 @@ class _DismissibleState extends State<Dismissible> with TickerProviderStateMixin
updateKeepAlive(); updateKeepAlive();
} }
Future<bool> _confirmStartResizeAnimation() async { Future<bool?> _confirmStartResizeAnimation() async {
if (widget.confirmDismiss != null) { if (widget.confirmDismiss != null) {
final DismissDirection direction = _dismissDirection!; final DismissDirection direction = _dismissDirection!;
assert(direction != null); assert(direction != null);
......
...@@ -300,7 +300,7 @@ class Hero extends StatefulWidget { ...@@ -300,7 +300,7 @@ class Hero extends StatefulWidget {
// the Hero is inside a nested Navigator and should only be // the Hero is inside a nested Navigator and should only be
// considered for animation if it is part of the top-most route in // considered for animation if it is part of the top-most route in
// that nested Navigator and if that route is also a PageRoute. // 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) { if (heroRoute != null && heroRoute is PageRoute && heroRoute.isCurrent) {
inviteHero(hero, tag); inviteHero(hero, tag);
} }
......
...@@ -450,7 +450,7 @@ class Localizations extends StatefulWidget { ...@@ -450,7 +450,7 @@ class Localizations extends StatefulWidget {
assert(context != null); assert(context != null);
assert(type != null); assert(type != null);
final _LocalizationsScope? scope = context.dependOnInheritedWidgetOfExactType<_LocalizationsScope>(); final _LocalizationsScope? scope = context.dependOnInheritedWidgetOfExactType<_LocalizationsScope>();
return scope?.localizationsState.resourcesFor<T>(type); return scope?.localizationsState.resourcesFor<T?>(type);
} }
@override @override
......
...@@ -159,7 +159,7 @@ class AnimatedModalBarrier extends AnimatedWidget { ...@@ -159,7 +159,7 @@ class AnimatedModalBarrier extends AnimatedWidget {
/// ///
/// * [ModalRoute.barrierColor], which controls this property for the /// * [ModalRoute.barrierColor], which controls this property for the
/// [AnimatedModalBarrier] built by [ModalRoute] pages. /// [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]. /// Whether touching the barrier will pop the current route off the [Navigator].
/// ///
......
...@@ -425,7 +425,7 @@ abstract class RestorableProperty<T> extends ChangeNotifier { ...@@ -425,7 +425,7 @@ abstract class RestorableProperty<T> extends ChangeNotifier {
/// [RestorableProperty]. Whenever new restoration data has been provided to /// [RestorableProperty]. Whenever new restoration data has been provided to
/// the [RestorationMixin] the property is registered to, either this method /// the [RestorationMixin] the property is registered to, either this method
/// or [createDefaultValue] is called before [initWithValue] is invoked. /// 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 /// Called by the [RestorationMixin] with the `value` returned by either
/// [createDefaultValue] or [fromPrimitives] to set the value that this /// [createDefaultValue] or [fromPrimitives] to set the value that this
...@@ -884,7 +884,7 @@ mixin RestorationMixin<S extends StatefulWidget> on State<S> { ...@@ -884,7 +884,7 @@ mixin RestorationMixin<S extends StatefulWidget> on State<S> {
/// restore the internal state of a [State] object, it may be removed from the /// restore the internal state of a [State] object, it may be removed from the
/// restoration data by calling this method. /// restoration data by calling this method.
@protected @protected
void unregisterFromRestoration(RestorableProperty<Object> property) { void unregisterFromRestoration(RestorableProperty<Object?> property) {
assert(property != null); assert(property != null);
assert(property._owner == this); assert(property._owner == this);
_bucket?.remove<Object?>(property._restorationId!); _bucket?.remove<Object?>(property._restorationId!);
......
...@@ -173,9 +173,9 @@ class _RestorablePrimitiveValue<T extends Object> extends RestorableValue<T> { ...@@ -173,9 +173,9 @@ class _RestorablePrimitiveValue<T extends Object> extends RestorableValue<T> {
} }
@override @override
T fromPrimitives(Object serialized) { T fromPrimitives(Object? serialized) {
assert(serialized != null); assert(serialized != null);
return serialized as T; return serialized! as T;
} }
@override @override
...@@ -360,8 +360,8 @@ class RestorableTextEditingController extends RestorableChangeNotifier<TextEditi ...@@ -360,8 +360,8 @@ class RestorableTextEditingController extends RestorableChangeNotifier<TextEditi
} }
@override @override
TextEditingController fromPrimitives(Object data) { TextEditingController fromPrimitives(Object? data) {
return TextEditingController(text: data as String); return TextEditingController(text: data! as String);
} }
@override @override
......
...@@ -62,7 +62,7 @@ abstract class OverlayRoute<T> extends Route<T> { ...@@ -62,7 +62,7 @@ abstract class OverlayRoute<T> extends Route<T> {
bool get finishedWhenPopped => true; bool get finishedWhenPopped => true;
@override @override
bool didPop(T result) { bool didPop(T? result) {
final bool returnValue = super.didPop(result); final bool returnValue = super.didPop(result);
assert(returnValue); assert(returnValue);
if (finishedWhenPopped) if (finishedWhenPopped)
...@@ -90,8 +90,8 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> { ...@@ -90,8 +90,8 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
/// This future completes once the animation has been dismissed. That will be /// This future completes once the animation has been dismissed. That will be
/// after [popped], because [popped] typically completes before the animation /// after [popped], because [popped] typically completes before the animation
/// even starts, as soon as the route is popped. /// even starts, as soon as the route is popped.
Future<T> get completed => _transitionCompleter.future; Future<T?> get completed => _transitionCompleter.future;
final Completer<T> _transitionCompleter = Completer<T>(); final Completer<T?> _transitionCompleter = Completer<T?>();
/// {@template flutter.widgets.transitionRoute.transitionDuration} /// {@template flutter.widgets.transitionRoute.transitionDuration}
/// The duration the transition going forwards. /// The duration the transition going forwards.
...@@ -235,7 +235,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> { ...@@ -235,7 +235,7 @@ abstract class TransitionRoute<T> extends OverlayRoute<T> {
} }
@override @override
bool didPop(T result) { bool didPop(T? result) {
assert(_controller != null, '$runtimeType.didPop called before calling install() or after calling dispose().'); assert(_controller != null, '$runtimeType.didPop called before calling install() or after calling dispose().');
assert(!_transitionCompleter.isCompleted, 'Cannot reuse a $runtimeType after disposing it.'); assert(!_transitionCompleter.isCompleted, 'Cannot reuse a $runtimeType after disposing it.');
_result = result; _result = result;
...@@ -631,7 +631,7 @@ mixin LocalHistoryRoute<T> on Route<T> { ...@@ -631,7 +631,7 @@ mixin LocalHistoryRoute<T> on Route<T> {
} }
@override @override
bool didPop(T result) { bool didPop(T? result) {
if (_localHistory != null && _localHistory!.isNotEmpty) { if (_localHistory != null && _localHistory!.isNotEmpty) {
final LocalHistoryEntry entry = _localHistory!.removeLast(); final LocalHistoryEntry entry = _localHistory!.removeLast();
assert(entry._owner == this); assert(entry._owner == this);
...@@ -1818,7 +1818,7 @@ class _DialogRoute<T> extends PopupRoute<T> { ...@@ -1818,7 +1818,7 @@ class _DialogRoute<T> extends PopupRoute<T> {
/// ///
/// * [showDialog], which displays a Material-style dialog. /// * [showDialog], which displays a Material-style dialog.
/// * [showCupertinoDialog], which displays an iOS-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 BuildContext context,
required RoutePageBuilder pageBuilder, required RoutePageBuilder pageBuilder,
bool barrierDismissible = false, bool barrierDismissible = false,
......
...@@ -1084,8 +1084,8 @@ class _RestorableScrollOffset extends RestorableValue<double?> { ...@@ -1084,8 +1084,8 @@ class _RestorableScrollOffset extends RestorableValue<double?> {
} }
@override @override
double fromPrimitives(Object data) { double fromPrimitives(Object? data) {
return data as double; return data! as double;
} }
@override @override
......
...@@ -303,16 +303,16 @@ class _TableElement extends RenderObjectElement { ...@@ -303,16 +303,16 @@ class _TableElement extends RenderObjectElement {
} }
@override @override
void insertRenderObjectChild(RenderObject child, IndexedSlot<Element>? slot) { void insertRenderObjectChild(RenderObject child, dynamic slot) {
renderObject.setupParentData(child); renderObject.setupParentData(child);
} }
@override @override
void moveRenderObjectChild(RenderObject child, IndexedSlot<Element>? oldSlot, IndexedSlot<Element>? newSlot) { void moveRenderObjectChild(RenderObject child, dynamic oldSlot, dynamic newSlot) {
} }
@override @override
void removeRenderObjectChild(RenderObject child, IndexedSlot<Element>? slot) { void removeRenderObjectChild(RenderObject child, dynamic slot) {
final TableCellParentData childParentData = child.parentData! as TableCellParentData; final TableCellParentData childParentData = child.parentData! as TableCellParentData;
renderObject.setChild(childParentData.x!, childParentData.y!, null); renderObject.setChild(childParentData.x!, childParentData.y!, null);
} }
......
...@@ -111,7 +111,7 @@ void main() { ...@@ -111,7 +111,7 @@ void main() {
test('Notifies onBytesReceived with gzipped numbers', () async { test('Notifies onBytesReceived with gzipped numbers', () async {
response.contentLength = gzipped.length; response.contentLength = gzipped.length;
final List<int?> records = <int>[]; final List<int?> records = <int?>[];
await consolidateHttpClientResponseBytes( await consolidateHttpClientResponseBytes(
response, response,
onBytesReceived: (int cumulative, int? total) { onBytesReceived: (int cumulative, int? total) {
......
...@@ -76,7 +76,7 @@ void main() { ...@@ -76,7 +76,7 @@ void main() {
test('subtreeDepth 1', () { test('subtreeDepth 1', () {
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 1)); final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 1));
expect(result.containsKey('properties'), isFalse); 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[0].containsKey('children'), isFalse);
expect(children[1].containsKey('children'), isFalse); expect(children[1].containsKey('children'), isFalse);
expect(children[2].containsKey('children'), isFalse); expect(children[2].containsKey('children'), isFalse);
...@@ -85,7 +85,7 @@ void main() { ...@@ -85,7 +85,7 @@ void main() {
test('subtreeDepth 5', () { test('subtreeDepth 5', () {
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 5)); final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 5));
expect(result.containsKey('properties'), isFalse); 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[0]['children'], hasLength(0));
expect(children[1]['children'], hasLength(3)); expect(children[1]['children'], hasLength(3));
expect(children[2]['children'], hasLength(0)); expect(children[2]['children'], hasLength(0));
...@@ -103,7 +103,7 @@ void main() { ...@@ -103,7 +103,7 @@ void main() {
subtreeDepth: 1, subtreeDepth: 1,
)); ));
expect(result['properties'], hasLength(7)); 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, hasLength(3));
expect(children[0]['properties'], hasLength(0)); expect(children[0]['properties'], hasLength(0));
expect(children[1]['properties'], hasLength(2)); expect(children[1]['properties'], hasLength(2));
...@@ -119,13 +119,13 @@ void main() { ...@@ -119,13 +119,13 @@ void main() {
}, },
)); ));
expect(result['foo'], isTrue); 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, 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, 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', () { test('filterProperties - sublist', () {
...@@ -135,9 +135,9 @@ void main() { ...@@ -135,9 +135,9 @@ void main() {
return nodes.whereType<StringProperty>().toList(); 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, 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', () { test('filterProperties - replace', () {
...@@ -154,7 +154,7 @@ void main() { ...@@ -154,7 +154,7 @@ void main() {
]; ];
}, },
)); ));
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, hasLength(1));
expect(properties.single['name'], 'foo'); expect(properties.single['name'], 'foo');
}); });
...@@ -166,7 +166,7 @@ void main() { ...@@ -166,7 +166,7 @@ void main() {
return nodes.where((DiagnosticsNode node) => node.getProperties().isEmpty).toList(); 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)); expect(children, hasLength(1));
}); });
...@@ -177,7 +177,7 @@ void main() { ...@@ -177,7 +177,7 @@ void main() {
return nodes.expand((DiagnosticsNode node) => node.getChildren()).toList(); 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, hasLength(3));
expect(children.first['name'], 'child node B1'); expect(children.first['name'], 'child node B1');
}); });
...@@ -190,11 +190,11 @@ void main() { ...@@ -190,11 +190,11 @@ void main() {
return nodes.take(2).toList(); 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, hasLength(3));
expect(children.last['truncated'], isTrue); 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, hasLength(3));
expect(properties.last['truncated'], isTrue); expect(properties.last['truncated'], isTrue);
}); });
...@@ -207,13 +207,13 @@ void main() { ...@@ -207,13 +207,13 @@ void main() {
return delegate.copyWith(includeProperties: false); 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, 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, hasLength(3));
expect(children.every((Map<String, Object> child) => !child.containsKey('properties')), isTrue); expect(children.every((Map<String, Object?> child) => !child.containsKey('properties')), isTrue);
}); });
}); });
} }
......
...@@ -47,15 +47,15 @@ enum ExampleEnum { ...@@ -47,15 +47,15 @@ enum ExampleEnum {
/// Encode and decode to JSON to make sure all objects in the JSON for the /// Encode and decode to JSON to make sure all objects in the JSON for the
/// [DiagnosticsNode] are valid JSON. /// [DiagnosticsNode] are valid JSON.
Map<String, Object> simulateJsonSerialization(DiagnosticsNode node) { Map<String, Object?> simulateJsonSerialization(DiagnosticsNode node) {
return json.decode(json.encode(node.toJsonMap(const DiagnosticsSerializationDelegate()))) as Map<String, Object>; return json.decode(json.encode(node.toJsonMap(const DiagnosticsSerializationDelegate()))) as Map<String, Object?>;
} }
void validateNodeJsonSerialization(DiagnosticsNode node) { void validateNodeJsonSerialization(DiagnosticsNode node) {
validateNodeJsonSerializationHelper(simulateJsonSerialization(node), 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['name'], equals(node.name));
expect(json['showSeparator'] ?? true, equals(node.showSeparator)); expect(json['showSeparator'] ?? true, equals(node.showSeparator));
expect(json['description'], equals(node.toDescription())); expect(json['description'], equals(node.toDescription()));
...@@ -67,18 +67,18 @@ void validateNodeJsonSerializationHelper(Map<String, Object> json, DiagnosticsNo ...@@ -67,18 +67,18 @@ void validateNodeJsonSerializationHelper(Map<String, Object> json, DiagnosticsNo
expect(json['hasChildren'] ?? false, equals(node.getChildren().isNotEmpty)); expect(json['hasChildren'] ?? false, equals(node.getChildren().isNotEmpty));
} }
void validatePropertyJsonSerialization(DiagnosticsProperty<Object> property) { void validatePropertyJsonSerialization(DiagnosticsProperty<Object?> property) {
validatePropertyJsonSerializationHelper(simulateJsonSerialization(property), property); validatePropertyJsonSerializationHelper(simulateJsonSerialization(property), property);
} }
void validateStringPropertyJsonSerialization(StringProperty 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)); expect(json['quoted'], equals(property.quoted));
validatePropertyJsonSerializationHelper(json, property); validatePropertyJsonSerializationHelper(json, property);
} }
void validateFlagPropertyJsonSerialization(FlagProperty 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)); expect(json['ifTrue'], equals(property.ifTrue));
if (property.ifTrue != null) { if (property.ifTrue != null) {
...@@ -96,7 +96,7 @@ void validateFlagPropertyJsonSerialization(FlagProperty property) { ...@@ -96,7 +96,7 @@ void validateFlagPropertyJsonSerialization(FlagProperty property) {
} }
void validateDoublePropertyJsonSerialization(DoubleProperty property) { void validateDoublePropertyJsonSerialization(DoubleProperty property) {
final Map<String, Object> json = simulateJsonSerialization(property); final Map<String, Object?> json = simulateJsonSerialization(property);
if (property.unit != null) { if (property.unit != null) {
expect(json['unit'], equals(property.unit)); expect(json['unit'], equals(property.unit));
} else { } else {
...@@ -109,7 +109,7 @@ void validateDoublePropertyJsonSerialization(DoubleProperty property) { ...@@ -109,7 +109,7 @@ void validateDoublePropertyJsonSerialization(DoubleProperty property) {
} }
void validateObjectFlagPropertyJsonSerialization(ObjectFlagProperty<Object> property) { void validateObjectFlagPropertyJsonSerialization(ObjectFlagProperty<Object> property) {
final Map<String, Object> json = simulateJsonSerialization(property); final Map<String, Object?> json = simulateJsonSerialization(property);
if (property.ifPresent != null) { if (property.ifPresent != null) {
expect(json['ifPresent'], equals(property.ifPresent)); expect(json['ifPresent'], equals(property.ifPresent));
} else { } else {
...@@ -120,7 +120,7 @@ void validateObjectFlagPropertyJsonSerialization(ObjectFlagProperty<Object> prop ...@@ -120,7 +120,7 @@ void validateObjectFlagPropertyJsonSerialization(ObjectFlagProperty<Object> prop
} }
void validateIterableFlagsPropertyJsonSerialization(FlagsSummary<Object?> property) { void validateIterableFlagsPropertyJsonSerialization(FlagsSummary<Object?> property) {
final Map<String, Object> json = simulateJsonSerialization(property); final Map<String, Object?> json = simulateJsonSerialization(property);
if (property.value.isNotEmpty) { if (property.value.isNotEmpty) {
expect(json['values'], equals( expect(json['values'], equals(
property.value.entries property.value.entries
...@@ -135,9 +135,9 @@ void validateIterableFlagsPropertyJsonSerialization(FlagsSummary<Object?> proper ...@@ -135,9 +135,9 @@ void validateIterableFlagsPropertyJsonSerialization(FlagsSummary<Object?> proper
} }
void validateIterablePropertyJsonSerialization(IterableProperty<Object> property) { void validateIterablePropertyJsonSerialization(IterableProperty<Object> property) {
final Map<String, Object> json = simulateJsonSerialization(property); final Map<String, Object?> json = simulateJsonSerialization(property);
if (property.value != null) { 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(); final List<String> expectedValues = property.value!.map<String>((Object value) => value.toString()).toList();
expect(listEquals(valuesJson, expectedValues), isTrue); expect(listEquals(valuesJson, expectedValues), isTrue);
} else { } else {
...@@ -147,7 +147,7 @@ void validateIterablePropertyJsonSerialization(IterableProperty<Object> property ...@@ -147,7 +147,7 @@ void validateIterablePropertyJsonSerialization(IterableProperty<Object> property
validatePropertyJsonSerializationHelper(json, property); 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) { if (property.defaultValue != kNoDefaultValue) {
expect(json['defaultValue'], equals(property.defaultValue.toString())); expect(json['defaultValue'], equals(property.defaultValue.toString()));
} else { } else {
...@@ -1919,7 +1919,7 @@ void main() { ...@@ -1919,7 +1919,7 @@ void main() {
expect(messageProperty.name, equals('diagnostics')); expect(messageProperty.name, equals('diagnostics'));
expect(messageProperty.value, isNull); expect(messageProperty.value, isNull);
expect(messageProperty.showName, isTrue); expect(messageProperty.showName, isTrue);
validatePropertyJsonSerialization(messageProperty as DiagnosticsProperty<Object>); validatePropertyJsonSerialization(messageProperty as DiagnosticsProperty<Object?>);
}); });
test('error message style wrap test', () { test('error message style wrap test', () {
...@@ -2246,7 +2246,7 @@ void main() { ...@@ -2246,7 +2246,7 @@ void main() {
test('DiagnosticsProperty for basic types has value in json', () { test('DiagnosticsProperty for basic types has value in json', () {
DiagnosticsProperty<int> intProperty = DiagnosticsProperty<int>('int1', 10); 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['name'], 'int1');
expect(json['value'], 10); expect(json['value'], 10);
......
...@@ -249,7 +249,7 @@ void main() { ...@@ -249,7 +249,7 @@ void main() {
}); });
testWidgets('Return value from pop is correct', (WidgetTester tester) async { testWidgets('Return value from pop is correct', (WidgetTester tester) async {
late Future<Object> result; late Future<Object?> result;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Builder( home: Builder(
...@@ -258,7 +258,7 @@ void main() { ...@@ -258,7 +258,7 @@ void main() {
child: ElevatedButton( child: ElevatedButton(
child: const Text('X'), child: const Text('X'),
onPressed: () async { onPressed: () async {
result = Navigator.of(context)!.pushNamed('/a'); result = Navigator.of(context)!.pushNamed<Object?>('/a');
}, },
), ),
); );
......
...@@ -233,7 +233,7 @@ void main() { ...@@ -233,7 +233,7 @@ void main() {
final BuildContext context = tester.element(find.text('Go')); final BuildContext context = tester.element(find.text('Go'));
final Future<int> result = showDialog<int>( final Future<int?> result = showDialog<int>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return SimpleDialog( return SimpleDialog(
...@@ -273,7 +273,7 @@ void main() { ...@@ -273,7 +273,7 @@ void main() {
), ),
); );
final Future<int> result = showDialog<int>( final Future<int?> result = showDialog<int>(
context: navigator.currentContext!, context: navigator.currentContext!,
builder: (BuildContext context) { builder: (BuildContext context) {
return SimpleDialog( return SimpleDialog(
...@@ -1382,7 +1382,7 @@ void main() { ...@@ -1382,7 +1382,7 @@ void main() {
final List<int> dismissedItems = <int>[]; final List<int> dismissedItems = <int>[];
// Dismiss is confirmed IFF confirmDismiss() returns true. // Dismiss is confirmed IFF confirmDismiss() returns true.
Future<bool> confirmDismiss (DismissDirection dismissDirection) { Future<bool?> confirmDismiss (DismissDirection dismissDirection) async {
return showDialog<bool>( return showDialog<bool>(
context: _scaffoldKey.currentContext!, context: _scaffoldKey.currentContext!,
barrierDismissible: true, // showDialog() returns null if tapped outside the dialog barrierDismissible: true, // showDialog() returns null if tapped outside the dialog
...@@ -1762,7 +1762,7 @@ void main() { ...@@ -1762,7 +1762,7 @@ void main() {
final BuildContext context = tester.element(find.text('Go')); final BuildContext context = tester.element(find.text('Go'));
const RouteSettings exampleSetting = RouteSettings(name: 'simple'); const RouteSettings exampleSetting = RouteSettings(name: 'simple');
final Future<int> result = showDialog<int>( final Future<int?> result = showDialog<int>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return SimpleDialog( return SimpleDialog(
......
...@@ -465,7 +465,7 @@ void main() { ...@@ -465,7 +465,7 @@ void main() {
final WidgetPredicate popupMenu = (Widget widget) { final WidgetPredicate popupMenu = (Widget widget) {
final String widgetType = widget.runtimeType.toString(); final String widgetType = widget.runtimeType.toString();
// TODO(mraleph): Remove the old case below. // 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 || widgetType == '_PopupMenu'; // for old versions of Dart that don't reify method type arguments
}; };
...@@ -794,7 +794,7 @@ void main() { ...@@ -794,7 +794,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// The position is different than the offset because the default position isn't at the origin. // 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 { testWidgets('open PopupMenu has correct semantics', (WidgetTester tester) async {
......
...@@ -80,7 +80,7 @@ void main() { ...@@ -80,7 +80,7 @@ void main() {
// regression test for https://github.com/flutter/flutter/issues/18145 // regression test for https://github.com/flutter/flutter/issues/18145
final _TestSearchDelegate delegate = _TestSearchDelegate(); final _TestSearchDelegate delegate = _TestSearchDelegate();
final List<String> selectedResults = <String>[]; final List<String?> selectedResults = <String?>[];
await tester.pumpWidget(TestHomePage( await tester.pumpWidget(TestHomePage(
delegate: delegate, delegate: delegate,
...@@ -105,7 +105,7 @@ void main() { ...@@ -105,7 +105,7 @@ void main() {
await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/navigation', message, (_) { }); await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/navigation', message, (_) { });
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(selectedResults, <void>[null]); expect(selectedResults, <String?>[null]);
// We are on the homepage again // We are on the homepage again
expect(find.text('HomeBody'), findsOneWidget); expect(find.text('HomeBody'), findsOneWidget);
...@@ -374,7 +374,7 @@ void main() { ...@@ -374,7 +374,7 @@ void main() {
}); });
testWidgets('Closing nested search returns to search', (WidgetTester tester) async { testWidgets('Closing nested search returns to search', (WidgetTester tester) async {
final List<String> nestedSearchResults = <String>[]; final List<String?> nestedSearchResults = <String?>[];
final _TestSearchDelegate nestedSearchDelegate = _TestSearchDelegate( final _TestSearchDelegate nestedSearchDelegate = _TestSearchDelegate(
suggestions: 'Nested Suggestions', suggestions: 'Nested Suggestions',
result: 'Nested Result', result: 'Nested Result',
...@@ -389,7 +389,7 @@ void main() { ...@@ -389,7 +389,7 @@ void main() {
tooltip: 'Nested Search', tooltip: 'Nested Search',
icon: const Icon(Icons.search), icon: const Icon(Icons.search),
onPressed: () async { onPressed: () async {
final String result = await showSearch( final String? result = await showSearch(
context: context, context: context,
delegate: nestedSearchDelegate, delegate: nestedSearchDelegate,
); );
...@@ -467,7 +467,7 @@ void main() { ...@@ -467,7 +467,7 @@ void main() {
tooltip: 'Nested Search', tooltip: 'Nested Search',
icon: const Icon(Icons.search), icon: const Icon(Icons.search),
onPressed: () async { onPressed: () async {
final String result = await showSearch( final String? result = await showSearch(
context: context, context: context,
delegate: nestedSearchDelegate, delegate: nestedSearchDelegate,
); );
...@@ -702,7 +702,7 @@ class TestHomePage extends StatelessWidget { ...@@ -702,7 +702,7 @@ class TestHomePage extends StatelessWidget {
this.initialQuery, this.initialQuery,
}) : super(key: key); }) : super(key: key);
final List<String>? results; final List<String?>? results;
final SearchDelegate<String> delegate; final SearchDelegate<String> delegate;
final bool passInInitialQuery; final bool passInInitialQuery;
final String? initialQuery; final String? initialQuery;
...@@ -719,7 +719,7 @@ class TestHomePage extends StatelessWidget { ...@@ -719,7 +719,7 @@ class TestHomePage extends StatelessWidget {
tooltip: 'Search', tooltip: 'Search',
icon: const Icon(Icons.search), icon: const Icon(Icons.search),
onPressed: () async { onPressed: () async {
String selectedResult; String? selectedResult;
if (passInInitialQuery) { if (passInInitialQuery) {
selectedResult = await showSearch<String>( selectedResult = await showSearch<String>(
context: context, context: context,
......
...@@ -222,8 +222,8 @@ void main() { ...@@ -222,8 +222,8 @@ void main() {
}); });
testWidgets('Form.willPop callbacks do not accumulate', (WidgetTester tester) async { testWidgets('Form.willPop callbacks do not accumulate', (WidgetTester tester) async {
Future<bool> showYesNoAlert(BuildContext context) { Future<bool> showYesNoAlert(BuildContext context) async {
return showDialog<bool>( return (await showDialog<bool>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return AlertDialog( return AlertDialog(
...@@ -239,7 +239,7 @@ void main() { ...@@ -239,7 +239,7 @@ void main() {
], ],
); );
}, },
); ))!;
} }
Widget buildFrame() { Widget buildFrame() {
......
...@@ -823,7 +823,6 @@ class _TestRecordingCanvasPatternMatcher extends _TestRecordingCanvasMatcher imp ...@@ -823,7 +823,6 @@ class _TestRecordingCanvasPatternMatcher extends _TestRecordingCanvasMatcher imp
while (predicate.moveNext()) { while (predicate.moveNext()) {
predicate.current.match(call); predicate.current.match(call);
} }
assert(predicate.current == null);
// We allow painting more than expected. // We allow painting more than expected.
} on _MismatchedCall catch (data) { } on _MismatchedCall catch (data) {
description.writeln(data.message); description.writeln(data.message);
......
...@@ -174,11 +174,11 @@ class FakeAndroidPlatformViewsController { ...@@ -174,11 +174,11 @@ class FakeAndroidPlatformViewsController {
final Map<dynamic, dynamic> args = call.arguments as Map<dynamic, dynamic>; final Map<dynamic, dynamic> args = call.arguments as Map<dynamic, dynamic>;
final int id = args['id'] as int; final int id = args['id'] as int;
final String viewType = args['viewType'] as String; final String viewType = args['viewType'] as String;
final double width = args['width'] as double; final double? width = args['width'] as double?;
final double height = args['height'] as double; final double? height = args['height'] as double?;
final int layoutDirection = args['direction'] as int; final int layoutDirection = args['direction'] as int;
final bool hybrid = args['hybrid'] as bool; final bool? hybrid = args['hybrid'] as bool?;
final Uint8List creationParams = args['params'] as Uint8List; final Uint8List? creationParams = args['params'] as Uint8List?;
if (_views.containsKey(id)) if (_views.containsKey(id))
throw PlatformException( throw PlatformException(
...@@ -197,7 +197,7 @@ class FakeAndroidPlatformViewsController { ...@@ -197,7 +197,7 @@ class FakeAndroidPlatformViewsController {
} }
_views[id] = FakeAndroidPlatformView(id, viewType, _views[id] = FakeAndroidPlatformView(id, viewType,
width != null || height != null ? Size(width, height) : null, width != null && height != null ? Size(width, height) : null,
layoutDirection, layoutDirection,
hybrid, hybrid,
creationParams, creationParams,
...@@ -344,7 +344,7 @@ class FakeIosPlatformViewsController { ...@@ -344,7 +344,7 @@ class FakeIosPlatformViewsController {
final Map<dynamic, dynamic> args = call.arguments as Map<dynamic, dynamic>; final Map<dynamic, dynamic> args = call.arguments as Map<dynamic, dynamic>;
final int id = args['id'] as int; final int id = args['id'] as int;
final String viewType = args['viewType'] as String; 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)) { if (_views.containsKey(id)) {
throw PlatformException( throw PlatformException(
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter/painting.dart'; import 'package:flutter/painting.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart' show TestWidgetsFlutterBinding; import 'package:flutter_test/flutter_test.dart' show TestWidgetsFlutterBinding;
......
...@@ -58,7 +58,7 @@ class MockPaintingContext extends Fake implements PaintingContext { ...@@ -58,7 +58,7 @@ class MockPaintingContext extends Fake implements PaintingContext {
void main() { void main() {
testWidgets('Control test for custom painting', (WidgetTester tester) async { testWidgets('Control test for custom painting', (WidgetTester tester) async {
final List<String> log = <String>[]; final List<String?> log = <String?>[];
await tester.pumpWidget(CustomPaint( await tester.pumpWidget(CustomPaint(
painter: TestCustomPainter( painter: TestCustomPainter(
log: log, log: log,
...@@ -82,7 +82,7 @@ void main() { ...@@ -82,7 +82,7 @@ void main() {
testWidgets('Throws FlutterError on custom painter incorrect restore/save calls', ( testWidgets('Throws FlutterError on custom painter incorrect restore/save calls', (
WidgetTester tester) async { WidgetTester tester) async {
final GlobalKey target = GlobalKey(); final GlobalKey target = GlobalKey();
final List<String> log = <String>[]; final List<String?> log = <String?>[];
await tester.pumpWidget(CustomPaint( await tester.pumpWidget(CustomPaint(
key: target, key: target,
isComplex: true, isComplex: true,
...@@ -174,7 +174,7 @@ void main() { ...@@ -174,7 +174,7 @@ void main() {
testWidgets('Raster cache hints', (WidgetTester tester) async { testWidgets('Raster cache hints', (WidgetTester tester) async {
final GlobalKey target = GlobalKey(); final GlobalKey target = GlobalKey();
final List<String> log = <String>[]; final List<String?> log = <String?>[];
await tester.pumpWidget(CustomPaint( await tester.pumpWidget(CustomPaint(
key: target, key: target,
isComplex: true, isComplex: true,
......
...@@ -18,7 +18,7 @@ const double crossAxisEndOffset = 0.5; ...@@ -18,7 +18,7 @@ const double crossAxisEndOffset = 0.5;
Widget buildTest({ Widget buildTest({
double? startToEndThreshold, double? startToEndThreshold,
TextDirection textDirection = TextDirection.ltr, TextDirection textDirection = TextDirection.ltr,
Future<bool> Function(BuildContext context, DismissDirection direction)? confirmDismiss, Future<bool?> Function(BuildContext context, DismissDirection direction)? confirmDismiss,
}) { }) {
return Directionality( return Directionality(
textDirection: textDirection, textDirection: textDirection,
...@@ -679,7 +679,7 @@ void main() { ...@@ -679,7 +679,7 @@ void main() {
return buildTest( return buildTest(
confirmDismiss: (BuildContext context, DismissDirection dismissDirection) { confirmDismiss: (BuildContext context, DismissDirection dismissDirection) {
confirmDismissDirection = dismissDirection; confirmDismissDirection = dismissDirection;
return Future<bool>.value(confirmDismissValue); return Future<bool?>.value(confirmDismissValue);
} }
); );
} }
......
...@@ -1516,7 +1516,7 @@ void main() { ...@@ -1516,7 +1516,7 @@ void main() {
expect(imageCache!.liveImageCount, 1); expect(imageCache!.liveImageCount, 1);
expect(imageCache!.containsKey(provider), false); 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, isNotNull);
expect(providerLocation.live, true); expect(providerLocation.live, true);
......
...@@ -957,7 +957,7 @@ void main() { ...@@ -957,7 +957,7 @@ void main() {
}); });
testWidgets('replaceNamed returned value', (WidgetTester tester) async { testWidgets('replaceNamed returned value', (WidgetTester tester) async {
late Future<String> value; late Future<String?> value;
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/' : (BuildContext context) => OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }), '/' : (BuildContext context) => OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }),
...@@ -1001,7 +1001,7 @@ void main() { ...@@ -1001,7 +1001,7 @@ void main() {
expect(find.text('A'), findsNothing); expect(find.text('A'), findsNothing);
expect(find.text('B'), 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'); expect(replaceNamedValue, 'B');
}); });
...@@ -1092,7 +1092,7 @@ void main() { ...@@ -1092,7 +1092,7 @@ void main() {
}); });
testWidgets('remove a route whose value is awaited', (WidgetTester tester) async { 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>{ final Map<String, WidgetBuilder> pageBuilders = <String, WidgetBuilder>{
'/': (BuildContext context) => OnTapPage(id: '/', onTap: () { pageValue = Navigator.pushNamed(context, '/A'); }), '/': (BuildContext context) => OnTapPage(id: '/', onTap: () { pageValue = Navigator.pushNamed(context, '/A'); }),
'/A': (BuildContext context) => OnTapPage(id: 'A', onTap: () { Navigator.pop(context, 'A'); }), '/A': (BuildContext context) => OnTapPage(id: 'A', onTap: () { Navigator.pop(context, 'A'); }),
...@@ -1113,7 +1113,7 @@ void main() { ...@@ -1113,7 +1113,7 @@ void main() {
await tester.tap(find.text('/')); // pushNamed('/A'), stack becomes /, /A await tester.tap(find.text('/')); // pushNamed('/A'), stack becomes /, /A
await tester.pumpAndSettle(); await tester.pumpAndSettle();
pageValue.then((String value) { assert(false); }); pageValue.then((String? value) { assert(false); });
final NavigatorState navigator = tester.state<NavigatorState>(find.byType(Navigator)); final NavigatorState navigator = tester.state<NavigatorState>(find.byType(Navigator));
navigator.removeRoute(routes['/A']!); // stack becomes /, pageValue will not complete navigator.removeRoute(routes['/A']!); // stack becomes /, pageValue will not complete
......
...@@ -285,7 +285,7 @@ void main() { ...@@ -285,7 +285,7 @@ void main() {
}); });
} }
class _TestRestorableValue extends RestorableValue<Object> { class _TestRestorableValue extends RestorableValue<Object?> {
@override @override
Object createDefaultValue() { Object createDefaultValue() {
return 55; return 55;
...@@ -300,12 +300,12 @@ class _TestRestorableValue extends RestorableValue<Object> { ...@@ -300,12 +300,12 @@ class _TestRestorableValue extends RestorableValue<Object> {
} }
@override @override
Object fromPrimitives(Object data) { Object? fromPrimitives(Object? data) {
return data; return data;
} }
@override @override
Object toPrimitives() { Object? toPrimitives() {
return value; return value;
} }
} }
......
...@@ -632,7 +632,7 @@ void main() { ...@@ -632,7 +632,7 @@ void main() {
}); });
test('RestorableProperty throws after disposed', () { test('RestorableProperty throws after disposed', () {
final RestorableProperty<Object> property = _TestRestorableProperty(10); final RestorableProperty<Object?> property = _TestRestorableProperty(10);
property.dispose(); property.dispose();
expect(() => property.dispose(), throwsFlutterError); expect(() => property.dispose(), throwsFlutterError);
}); });
...@@ -660,8 +660,8 @@ class _TestRestorableWidgetState extends State<_TestRestorableWidget> with Resto ...@@ -660,8 +660,8 @@ class _TestRestorableWidgetState extends State<_TestRestorableWidget> with Resto
_TestRestorableProperty? additionalProperty; _TestRestorableProperty? additionalProperty;
bool _rerigisterAdditionalProperty = false; bool _rerigisterAdditionalProperty = false;
final List<RestorationBucket?> restoreStateLog = <RestorationBucket>[]; final List<RestorationBucket?> restoreStateLog = <RestorationBucket?>[];
final List<RestorationBucket?> toggleBucketLog = <RestorationBucket>[]; final List<RestorationBucket?> toggleBucketLog = <RestorationBucket?>[];
@override @override
void restoreState(RestorationBucket? oldBucket, bool initialRestore) { void restoreState(RestorationBucket? oldBucket, bool initialRestore) {
...@@ -737,7 +737,7 @@ Map<String, dynamic> _createRawDataSet() { ...@@ -737,7 +737,7 @@ Map<String, dynamic> _createRawDataSet() {
}; };
} }
class _TestRestorableProperty extends RestorableProperty<Object> { class _TestRestorableProperty extends RestorableProperty<Object?> {
_TestRestorableProperty(this._value); _TestRestorableProperty(this._value);
List<String> log = <String>[]; List<String> log = <String>[];
...@@ -751,35 +751,35 @@ class _TestRestorableProperty extends RestorableProperty<Object> { ...@@ -751,35 +751,35 @@ class _TestRestorableProperty extends RestorableProperty<Object> {
} }
@override @override
Object createDefaultValue() { Object? createDefaultValue() {
log.add('createDefaultValue'); log.add('createDefaultValue');
return _value; return _value;
} }
@override @override
Object fromPrimitives(Object data) { Object? fromPrimitives(Object? data) {
log.add('fromPrimitives'); log.add('fromPrimitives');
return data; return data;
} }
Object get value { Object? get value {
assert(isRegistered); assert(isRegistered);
return _value; return _value;
} }
Object _value; Object? _value;
set value(Object value) { set value(Object? value) {
_value = value; _value = value;
notifyListeners(); notifyListeners();
} }
@override @override
void initWithValue(Object v) { void initWithValue(Object? v) {
log.add('initWithValue'); log.add('initWithValue');
_value = v; _value = v;
} }
@override @override
Object toPrimitives() { Object? toPrimitives() {
log.add('toPrimitives'); log.add('toPrimitives');
return _value; return _value;
} }
......
...@@ -209,7 +209,7 @@ class TestWidget extends StatefulWidget { ...@@ -209,7 +209,7 @@ class TestWidget extends StatefulWidget {
} }
class TestWidgetState extends State<TestWidget> with RestorationMixin { class TestWidgetState extends State<TestWidget> with RestorationMixin {
List<RestorationBucket?> buckets = <RestorationBucket>[]; List<RestorationBucket?> buckets = <RestorationBucket?>[];
List<bool> flags = <bool>[]; List<bool> flags = <bool>[];
@override @override
......
...@@ -302,7 +302,7 @@ void main() { ...@@ -302,7 +302,7 @@ void main() {
}); });
testWidgets('injects null when rootBucket is null', (WidgetTester tester) async { 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; binding.restorationManager.rootBucket = completer.future;
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -1319,28 +1319,28 @@ void main() { ...@@ -1319,28 +1319,28 @@ void main() {
final Finder animatedModalBarrier = find.byType(AnimatedModalBarrier); final Finder animatedModalBarrier = find.byType(AnimatedModalBarrier);
expect(animatedModalBarrier, findsOneWidget); expect(animatedModalBarrier, findsOneWidget);
Animation<Color> modalBarrierAnimation; Animation<Color?> modalBarrierAnimation;
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect(modalBarrierAnimation.value, Colors.transparent); expect(modalBarrierAnimation.value, Colors.transparent);
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect( expect(
modalBarrierAnimation.value.alpha, modalBarrierAnimation.value!.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.25), 1), closeTo(_getExpectedBarrierTweenAlphaValue(0.25), 1),
); );
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect( expect(
modalBarrierAnimation.value.alpha, modalBarrierAnimation.value!.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.50), 1), closeTo(_getExpectedBarrierTweenAlphaValue(0.50), 1),
); );
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect( expect(
modalBarrierAnimation.value.alpha, modalBarrierAnimation.value!.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.75), 1), closeTo(_getExpectedBarrierTweenAlphaValue(0.75), 1),
); );
...@@ -1382,28 +1382,28 @@ void main() { ...@@ -1382,28 +1382,28 @@ void main() {
final Finder animatedModalBarrier = find.byType(AnimatedModalBarrier); final Finder animatedModalBarrier = find.byType(AnimatedModalBarrier);
expect(animatedModalBarrier, findsOneWidget); expect(animatedModalBarrier, findsOneWidget);
Animation<Color> modalBarrierAnimation; Animation<Color?> modalBarrierAnimation;
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect(modalBarrierAnimation.value, Colors.transparent); expect(modalBarrierAnimation.value, Colors.transparent);
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect( expect(
modalBarrierAnimation.value.alpha, modalBarrierAnimation.value!.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.25), 1), closeTo(_getExpectedBarrierTweenAlphaValue(0.25), 1),
); );
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect( expect(
modalBarrierAnimation.value.alpha, modalBarrierAnimation.value!.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.50), 1), closeTo(_getExpectedBarrierTweenAlphaValue(0.50), 1),
); );
await tester.pump(const Duration(milliseconds: 25)); await tester.pump(const Duration(milliseconds: 25));
modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color; modalBarrierAnimation = tester.widget<AnimatedModalBarrier>(animatedModalBarrier).color;
expect( expect(
modalBarrierAnimation.value.alpha, modalBarrierAnimation.value!.alpha,
closeTo(_getExpectedBarrierTweenAlphaValue(0.75), 1), closeTo(_getExpectedBarrierTweenAlphaValue(0.75), 1),
); );
......
...@@ -49,27 +49,31 @@ class MatchesGoldenFile extends AsyncMatcher { ...@@ -49,27 +49,31 @@ class MatchesGoldenFile extends AsyncMatcher {
@override @override
Future<String?> matchAsync(dynamic item) async { Future<String?> matchAsync(dynamic item) async {
Future<ui.Image> imageFuture; Future<ui.Image?> imageFuture;
if (item is Future<ui.Image>) { if (item is Future<ui.Image?>) {
imageFuture = item; imageFuture = item;
} else if (item is ui.Image) { } else if (item is ui.Image) {
imageFuture = Future<ui.Image>.value(item); imageFuture = Future<ui.Image>.value(item);
} else { } else if (item is Finder) {
final Finder finder = item as Finder; final Iterable<Element> elements = item.evaluate();
final Iterable<Element> elements = finder.evaluate();
if (elements.isEmpty) { if (elements.isEmpty) {
return 'could not be rendered because no widget was found'; return 'could not be rendered because no widget was found';
} else if (elements.length > 1) { } else if (elements.length > 1) {
return 'matched too many widgets'; return 'matched too many widgets';
} }
imageFuture = captureImage(elements.single); imageFuture = captureImage(elements.single);
} else {
throw 'must provide a Finder, Image, or Future<Image>';
} }
final Uri testNameUri = goldenFileComparator.getTestUri(key, version); final Uri testNameUri = goldenFileComparator.getTestUri(key, version);
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding; final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
return binding.runAsync<String?>(() async { 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); final ByteData? bytes = await image.toByteData(format: ui.ImageByteFormat.png);
if (bytes == null) if (bytes == null)
return 'could not encode screenshot.'; return 'could not encode screenshot.';
......
...@@ -1011,17 +1011,19 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -1011,17 +1011,19 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
addTime(additionalTime); addTime(additionalTime);
return realAsyncZone.run<Future<T>>(() { return realAsyncZone.run<Future<T?>>(() async {
_pendingAsyncTasks = Completer<void>(); _pendingAsyncTasks = Completer<void>();
return callback().catchError((Object exception, StackTrace stack) { T? result;
try {
result = await callback();
} catch (exception, stack) {
FlutterError.reportError(FlutterErrorDetails( FlutterError.reportError(FlutterErrorDetails(
exception: exception, exception: exception,
stack: stack, stack: stack,
library: 'Flutter test framework', library: 'Flutter test framework',
context: ErrorDescription('while running async test code'), context: ErrorDescription('while running async test code'),
)); ));
return null; } finally {
}).whenComplete(() {
// We complete the _pendingAsyncTasks future successfully regardless of // We complete the _pendingAsyncTasks future successfully regardless of
// whether an exception occurred because in the case of an exception, // whether an exception occurred because in the case of an exception,
// we already reported the exception to FlutterError. Moreover, // we already reported the exception to FlutterError. Moreover,
...@@ -1029,7 +1031,8 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { ...@@ -1029,7 +1031,8 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
// exception due to zone error boundaries. // exception due to zone error boundaries.
_pendingAsyncTasks!.complete(); _pendingAsyncTasks!.complete();
_pendingAsyncTasks = null; _pendingAsyncTasks = null;
}); }
return result;
}); });
} }
......
...@@ -11,7 +11,7 @@ void testConfig( ...@@ -11,7 +11,7 @@ void testConfig(
String? expectedStringValue, { String? expectedStringValue, {
Map<Type, dynamic> otherExpectedValues = const <Type, dynamic>{int: isNull}, 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>( final Map<Type, dynamic> otherActualValues = otherExpectedValues.map<Type, dynamic>(
(Type key, dynamic value) { (Type key, dynamic value) {
return MapEntry<Type, dynamic>(key, Zone.current[key]); return MapEntry<Type, dynamic>(key, Zone.current[key]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment