diff --git a/packages/flutter_test/test/accessibility_test.dart b/packages/flutter_test/test/accessibility_test.dart index fa4a7cf0d49..1d4d2e922c8 100644 --- a/packages/flutter_test/test/accessibility_test.dart +++ b/packages/flutter_test/test/accessibility_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -181,7 +179,7 @@ void main() { }); group('custom minimum contrast guideline', () { - Widget _icon ({IconData icon = Icons.search, Color color, Color background}) { + Widget _icon({IconData icon = Icons.search, required Color color, required Color background}) { return Container( padding: const EdgeInsets.all(8.0), color: background, @@ -189,7 +187,7 @@ void main() { ); } - Widget _text ({String text = 'Text', Color color, Color background}) { + Widget _text({String text = 'Text', required Color color, required Color background}) { return Container( padding: const EdgeInsets.all(8.0), color: background, @@ -197,7 +195,7 @@ void main() { ); } - Widget _row (List widgets) => _boilerplate(Row(children: widgets)); + Widget _row(List widgets) => _boilerplate(Row(children: widgets)); final Finder _findIcons = find.byWidgetPredicate((Widget widget) => widget is Icon); final Finder _findTexts = find.byWidgetPredicate((Widget widget) => widget is Text); @@ -205,8 +203,8 @@ void main() { testWidgets('Black icons on white background', (WidgetTester tester) async { await tester.pumpWidget(_row([ - _icon (color: Colors.black, background: Colors.white), - _icon (color: Colors.black, background: Colors.white), + _icon(color: Colors.black, background: Colors.white), + _icon(color: Colors.black, background: Colors.white), ])); await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); @@ -214,8 +212,8 @@ void main() { testWidgets('Black icons on black background', (WidgetTester tester) async { await tester.pumpWidget(_row([ - _icon (color: Colors.black, background: Colors.black), - _icon (color: Colors.black, background: Colors.black), + _icon(color: Colors.black, background: Colors.black), + _icon(color: Colors.black, background: Colors.black), ])); await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); @@ -223,8 +221,8 @@ void main() { testWidgets('White icons on black background ("dark mode")', (WidgetTester tester) async { await tester.pumpWidget(_row([ - _icon (color: Colors.white, background: Colors.black), - _icon (color: Colors.white, background: Colors.black), + _icon(color: Colors.white, background: Colors.black), + _icon(color: Colors.white, background: Colors.black), ])); await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); @@ -232,10 +230,10 @@ void main() { testWidgets('Using different icons', (WidgetTester tester) async { await tester.pumpWidget(_row([ - _icon (color: Colors.black, background: Colors.white, icon: Icons.more_horiz), - _icon (color: Colors.black, background: Colors.white, icon: Icons.description), - _icon (color: Colors.black, background: Colors.white, icon: Icons.image), - _icon (color: Colors.black, background: Colors.white, icon: Icons.beach_access), + _icon(color: Colors.black, background: Colors.white, icon: Icons.more_horiz), + _icon(color: Colors.black, background: Colors.white, icon: Icons.description), + _icon(color: Colors.black, background: Colors.white, icon: Icons.image), + _icon(color: Colors.black, background: Colors.white, icon: Icons.beach_access), ])); await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); @@ -243,8 +241,8 @@ void main() { testWidgets('One invalid instance fails entire test', (WidgetTester tester) async { await tester.pumpWidget(_row([ - _icon (color: Colors.black, background: Colors.white), - _icon (color: Colors.black, background: Colors.black), + _icon(color: Colors.black, background: Colors.white), + _icon(color: Colors.black, background: Colors.black), ])); await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); @@ -252,10 +250,10 @@ void main() { testWidgets('White on different colors, passing', (WidgetTester tester) async { await tester.pumpWidget(_row([ - _icon (color: Colors.white, background: Colors.red[800], icon: Icons.more_horiz), - _icon (color: Colors.white, background: Colors.green[800], icon: Icons.description), - _icon (color: Colors.white, background: Colors.blue[800], icon: Icons.image), - _icon (color: Colors.white, background: Colors.purple[800], icon: Icons.beach_access), + _icon(color: Colors.white, background: Colors.red[800]!, icon: Icons.more_horiz), + _icon(color: Colors.white, background: Colors.green[800]!, icon: Icons.description), + _icon(color: Colors.white, background: Colors.blue[800]!, icon: Icons.image), + _icon(color: Colors.white, background: Colors.purple[800]!, icon: Icons.beach_access), ])); await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); @@ -263,10 +261,10 @@ void main() { testWidgets('White on different colors, failing', (WidgetTester tester) async { await tester.pumpWidget(_row([ - _icon (color: Colors.white, background: Colors.red[200], icon: Icons.more_horiz), - _icon (color: Colors.white, background: Colors.green[400], icon: Icons.description), - _icon (color: Colors.white, background: Colors.blue[600], icon: Icons.image), - _icon (color: Colors.white, background: Colors.purple[800], icon: Icons.beach_access), + _icon(color: Colors.white, background: Colors.red[200]!, icon: Icons.more_horiz), + _icon(color: Colors.white, background: Colors.green[400]!, icon: Icons.description), + _icon(color: Colors.white, background: Colors.blue[600]!, icon: Icons.image), + _icon(color: Colors.white, background: Colors.purple[800]!, icon: Icons.beach_access), ])); await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); @@ -280,8 +278,8 @@ void main() { testWidgets('Absence of icons, passing - 2nd test', (WidgetTester tester) async { await tester.pumpWidget(_row([ - _text (color: Colors.black, background: Colors.white), - _text (color: Colors.black, background: Colors.black), + _text(color: Colors.black, background: Colors.white), + _text(color: Colors.black, background: Colors.black), ])); await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); @@ -289,10 +287,10 @@ void main() { testWidgets('Guideline ignores widgets of other types', (WidgetTester tester) async { await tester.pumpWidget(_row([ - _icon (color: Colors.black, background: Colors.white), - _icon (color: Colors.black, background: Colors.white), - _text (color: Colors.black, background: Colors.white), - _text (color: Colors.black, background: Colors.black), + _icon(color: Colors.black, background: Colors.white), + _icon(color: Colors.black, background: Colors.white), + _text(color: Colors.black, background: Colors.white), + _text(color: Colors.black, background: Colors.black), ])); await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); @@ -302,8 +300,8 @@ void main() { testWidgets('Custom minimum ratio - Icons', (WidgetTester tester) async { await tester.pumpWidget(_row([ - _icon (color: Colors.blue, background: Colors.white), - _icon (color: Colors.black, background: Colors.white), + _icon(color: Colors.blue, background: Colors.white), + _icon(color: Colors.black, background: Colors.white), ])); await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); @@ -312,8 +310,8 @@ void main() { testWidgets('Custom minimum ratio - Texts', (WidgetTester tester) async { await tester.pumpWidget(_row([ - _text (color: Colors.blue, background: Colors.white), - _text (color: Colors.black, background: Colors.white), + _text(color: Colors.blue, background: Colors.white), + _text(color: Colors.black, background: Colors.white), ])); await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findTexts))); @@ -322,10 +320,10 @@ void main() { testWidgets('Custom minimum ratio - Different standards for icons and texts', (WidgetTester tester) async { await tester.pumpWidget(_row([ - _icon (color: Colors.blue, background: Colors.white), - _icon (color: Colors.black, background: Colors.white), - _text (color: Colors.blue, background: Colors.white), - _text (color: Colors.black, background: Colors.white), + _icon(color: Colors.blue, background: Colors.white), + _icon(color: Colors.black, background: Colors.white), + _text(color: Colors.blue, background: Colors.white), + _text(color: Colors.black, background: Colors.white), ])); await expectLater(tester, doesNotMeetGuideline(CustomMinimumContrastGuideline(finder: _findIcons))); diff --git a/packages/flutter_test/test/accessibility_window_test.dart b/packages/flutter_test/test/accessibility_window_test.dart index a15be991809..e84dd2ce467 100644 --- a/packages/flutter_test/test/accessibility_window_test.dart +++ b/packages/flutter_test/test/accessibility_window_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter_test/test/bindings_async_gap_test.dart b/packages/flutter_test/test/bindings_async_gap_test.dart index dbfc4bc00c4..ef30cc1da2a 100644 --- a/packages/flutter_test/test/bindings_async_gap_test.dart +++ b/packages/flutter_test/test/bindings_async_gap_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; import 'package:flutter/foundation.dart'; diff --git a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_false_test.dart b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_false_test.dart index 990a47bbe7a..394954841f8 100644 --- a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_false_test.dart +++ b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_false_test.dart @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - -import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_not_true_or_false_test.dart b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_not_true_or_false_test.dart index 1d1b6a1668b..9e9ed86c656 100644 --- a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_not_true_or_false_test.dart +++ b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_not_true_or_false_test.dart @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - -import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_null_test.dart b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_null_test.dart deleted file mode 100644 index 3b335ccfbf4..00000000000 --- a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_null_test.dart +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// @dart = 2.9 - -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - test('$WidgetsBinding initializes with $AutomatedTestWidgetsFlutterBinding when FLUTTER_TEST is defined but null', () { - TestWidgetsFlutterBinding.ensureInitialized({'FLUTTER_TEST': null}); - expect(WidgetsBinding.instance, isA()); - }); -} diff --git a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_true_test.dart b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_true_test.dart index 177554549ae..f9e9edbd214 100644 --- a/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_true_test.dart +++ b/packages/flutter_test/test/bindings_environment/flutter_test_variable_is_true_test.dart @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - -import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter_test/test/bindings_environment/no_flutter_test_variable_test.dart b/packages/flutter_test/test/bindings_environment/no_flutter_test_variable_test.dart index a88e01e37f2..2a6b064f40b 100644 --- a/packages/flutter_test/test/bindings_environment/no_flutter_test_variable_test.dart +++ b/packages/flutter_test/test/bindings_environment/no_flutter_test_variable_test.dart @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - -import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter_test/test/bindings_test.dart b/packages/flutter_test/test/bindings_test.dart index 0769ac05d20..15e14318c3e 100644 --- a/packages/flutter_test/test/bindings_test.dart +++ b/packages/flutter_test/test/bindings_test.dart @@ -2,11 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:io'; -import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter_test/test/bindings_test_failure.dart b/packages/flutter_test/test/bindings_test_failure.dart index e9f991c3790..4d5866b01f5 100644 --- a/packages/flutter_test/test/bindings_test_failure.dart +++ b/packages/flutter_test/test/bindings_test_failure.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:io'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter_test/test/controller_test.dart b/packages/flutter_test/test/controller_test.dart index 62aea3bd466..9734cc28eab 100644 --- a/packages/flutter_test/test/controller_test.dart +++ b/packages/flutter_test/test/controller_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:ui'; import 'package:flutter/semantics.dart'; diff --git a/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart b/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart index 471efc4fb67..6e92939a831 100644 --- a/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart +++ b/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; import 'package:flutter/foundation.dart'; diff --git a/packages/flutter_test/test/custom_exception_reporter/test_exception_reporter_test.dart b/packages/flutter_test/test/custom_exception_reporter/test_exception_reporter_test.dart index 390c2a19229..e24464d955b 100644 --- a/packages/flutter_test/test/custom_exception_reporter/test_exception_reporter_test.dart +++ b/packages/flutter_test/test/custom_exception_reporter/test_exception_reporter_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'flutter_test_config.dart' as real_test; void main() => real_test.runTest(); diff --git a/packages/flutter_test/test/demangle_test.dart b/packages/flutter_test/test/demangle_test.dart index 28966d70240..2f76f436699 100644 --- a/packages/flutter_test/test/demangle_test.dart +++ b/packages/flutter_test/test/demangle_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; import 'package:flutter/foundation.dart'; @@ -38,7 +36,7 @@ Future main() async { await binding.runTest(() async { final DebugPrintCallback oldDebugPrint = debugPrint; try { - debugPrint = (String message, {int wrapWidth}) {}; + debugPrint = (String? message, {int? wrapWidth}) {}; debugPrintStack( stackTrace: await getMangledStack(), ); diff --git a/packages/flutter_test/test/event_simulation_test.dart b/packages/flutter_test/test/event_simulation_test.dart index e08e672e850..91fefce391a 100644 --- a/packages/flutter_test/test/event_simulation_test.dart +++ b/packages/flutter_test/test/event_simulation_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter_test/test/finders_test.dart b/packages/flutter_test/test/finders_test.dart index 7f48ed7e6df..1d7ffa52fd0 100644 --- a/packages/flutter_test/test/finders_test.dart +++ b/packages/flutter_test/test/finders_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'package:flutter/rendering.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; diff --git a/packages/flutter_test/test/frame_timing_summarizer_test.dart b/packages/flutter_test/test/frame_timing_summarizer_test.dart index 8433a54d12a..ff3ee8fb4cd 100644 --- a/packages/flutter_test/test/frame_timing_summarizer_test.dart +++ b/packages/flutter_test/test/frame_timing_summarizer_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:ui'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter_test/test/goldens_test.dart b/packages/flutter_test/test/goldens_test.dart index 66193312b49..6ed20e058a3 100644 --- a/packages/flutter_test/test/goldens_test.dart +++ b/packages/flutter_test/test/goldens_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; import 'dart:io' as io; import 'dart:typed_data'; @@ -35,7 +33,7 @@ const List _kSizeFailurePngBytes = 0, 0, 73, 69, 78, 68, 174, 66, 96, 130]; void main() { - MemoryFileSystem fs; + late MemoryFileSystem fs; setUp(() { final FileSystemStyle style = io.Platform.isWindows @@ -86,7 +84,7 @@ void main() { }); group('LocalFileComparator', () { - LocalFileComparator comparator; + late LocalFileComparator comparator; setUp(() { comparator = LocalFileComparator(fs.file(fix('/golden_test.dart')).uri, pathStyle: fs.path.style); diff --git a/packages/flutter_test/test/integration_bindings_test.dart b/packages/flutter_test/test/integration_bindings_test.dart index 8f7b683401e..fd5f3428d02 100644 --- a/packages/flutter_test/test/integration_bindings_test.dart +++ b/packages/flutter_test/test/integration_bindings_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:io'; import 'package:flutter/widgets.dart'; diff --git a/packages/flutter_test/test/live_binding_test.dart b/packages/flutter_test/test/live_binding_test.dart index 23e0bff3d99..e64d468bf81 100644 --- a/packages/flutter_test/test/live_binding_test.dart +++ b/packages/flutter_test/test/live_binding_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:ui'; import 'package:flutter/material.dart'; @@ -24,7 +22,7 @@ void main() { }); testWidgets('Input PointerHoverEvent', (WidgetTester tester) async { - PointerHoverEvent hoverEvent; + PointerHoverEvent? hoverEvent; await tester.pumpWidget(MaterialApp(home: MouseRegion( child: const Text('Test'), onHover: (PointerHoverEvent event){ @@ -37,7 +35,7 @@ void main() { // for mouse input without a down event, moveTo generates a hover event await gesture.moveTo(location); expect(hoverEvent, isNotNull); - expect(hoverEvent.position, location); + expect(hoverEvent!.position, location); await gesture.removePointer(); }); } diff --git a/packages/flutter_test/test/live_widget_controller_test.dart b/packages/flutter_test/test/live_widget_controller_test.dart index a04152c9549..485e4145e46 100644 --- a/packages/flutter_test/test/live_widget_controller_test.dart +++ b/packages/flutter_test/test/live_widget_controller_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:ui'; import 'package:flutter/material.dart'; @@ -38,7 +36,7 @@ class AnimateSample extends StatefulWidget { class _AnimateSampleState extends State with SingleTickerProviderStateMixin { - AnimationController _controller; + late AnimationController _controller; @override void initState() { @@ -68,9 +66,9 @@ void main() { test('Test pump on LiveWidgetController', () async { runApp(MaterialApp(home: Center(child: CountButton()))); - await SchedulerBinding.instance.endOfFrame; + await SchedulerBinding.instance!.endOfFrame; final WidgetController controller = - LiveWidgetController(WidgetsBinding.instance); + LiveWidgetController(WidgetsBinding.instance!); await controller.tap(find.text('Counter 0')); expect(find.text('Counter 0'), findsOneWidget); expect(find.text('Counter 1'), findsNothing); @@ -81,9 +79,9 @@ void main() { test('Test pumpAndSettle on LiveWidgetController', () async { runApp(MaterialApp(home: Center(child: AnimateSample()))); - await SchedulerBinding.instance.endOfFrame; + await SchedulerBinding.instance!.endOfFrame; final WidgetController controller = - LiveWidgetController(WidgetsBinding.instance); + LiveWidgetController(WidgetsBinding.instance!); expect(find.text('Value: 1.0'), findsNothing); await controller.pumpAndSettle(); expect(find.text('Value: 1.0'), findsOneWidget); @@ -101,9 +99,9 @@ void main() { ), ), ); - await SchedulerBinding.instance.endOfFrame; + await SchedulerBinding.instance!.endOfFrame; final WidgetController controller = - LiveWidgetController(WidgetsBinding.instance); + LiveWidgetController(WidgetsBinding.instance!); final Offset location = controller.getCenter(find.text('test')); final List records = [ diff --git a/packages/flutter_test/test/matchers_test.dart b/packages/flutter_test/test/matchers_test.dart index 2668fbbb35d..121d4ca2408 100644 --- a/packages/flutter_test/test/matchers_test.dart +++ b/packages/flutter_test/test/matchers_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:typed_data'; import 'dart:ui'; @@ -13,9 +11,8 @@ import 'package:flutter_test/flutter_test.dart'; /// Class that makes it easy to mock common toStringDeep behavior. class _MockToStringDeep { - _MockToStringDeep(String str) { + _MockToStringDeep(String str) : _lines = [] { final List lines = str.split('\n'); - _lines = []; for (int i = 0; i < lines.length - 1; ++i) _lines.add('${lines[i]}\n'); @@ -31,7 +28,7 @@ class _MockToStringDeep { /// Lines in the message to display when [toStringDeep] is called. /// For correct toStringDeep behavior, each line should be terminated with a /// line break. - List _lines; + final List _lines; String toStringDeep({ String prefixLineOne = '', String prefixOtherLines = '' }) { final StringBuffer sb = StringBuffer(); @@ -340,7 +337,7 @@ void main() { }); group('matchesGoldenFile', () { - _FakeComparator comparator; + late _FakeComparator comparator; Widget boilerplate(Widget child) { return Directionality( @@ -561,8 +558,7 @@ void main() { currentValueLength: 10, maxValueLength: 15, ); - final _FakeSemanticsNode node = _FakeSemanticsNode(); - node.data = data; + final _FakeSemanticsNode node = _FakeSemanticsNode(data); expect(node, matchesSemantics( rect: const Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), @@ -666,9 +662,9 @@ enum _ComparatorInvocation { class _FakeComparator implements GoldenFileComparator { _ComparatorBehavior behavior = _ComparatorBehavior.returnTrue; - _ComparatorInvocation invocation; - Uint8List imageBytes; - Uri golden; + _ComparatorInvocation? invocation; + Uint8List? imageBytes; + Uri? golden; @override Future compare(Uint8List imageBytes, Uri golden) { @@ -683,7 +679,6 @@ class _FakeComparator implements GoldenFileComparator { case _ComparatorBehavior.throwTestFailure: throw TestFailure('fake message'); } - return Future.value(false); } @override @@ -695,12 +690,14 @@ class _FakeComparator implements GoldenFileComparator { } @override - Uri getTestUri(Uri key, int version) { + Uri getTestUri(Uri key, int? version) { return key; } } class _FakeSemanticsNode extends SemanticsNode { + _FakeSemanticsNode(this.data); + SemanticsData data; @override SemanticsData getSemanticsData() => data; @@ -709,7 +706,7 @@ class _FakeSemanticsNode extends SemanticsNode { @immutable class _CustomColor extends Color { const _CustomColor(int value, {this.isEqual}) : super(value); - final bool isEqual; + final bool? isEqual; @override bool operator ==(Object other) => isEqual ?? super == other; diff --git a/packages/flutter_test/test/reference_image_test.dart b/packages/flutter_test/test/reference_image_test.dart index 8a67660646d..add664c4bbd 100644 --- a/packages/flutter_test/test/reference_image_test.dart +++ b/packages/flutter_test/test/reference_image_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:ui' as ui; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter_test/test/restoration_test.dart b/packages/flutter_test/test/restoration_test.dart index 92d10d891d4..2168d60d126 100644 --- a/packages/flutter_test/test/restoration_test.dart +++ b/packages/flutter_test/test/restoration_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -75,9 +73,9 @@ void main() { } class _RestorableWidget extends StatefulWidget { - const _RestorableWidget({Key key, this.restorationId}) : super(key: key); + const _RestorableWidget({Key? key, this.restorationId}) : super(key: key); - final String restorationId; + final String? restorationId; @override State<_RestorableWidget> createState() => _RestorableWidgetState(); @@ -90,7 +88,7 @@ class _RestorableWidgetState extends State<_RestorableWidget> with RestorationMi double doubleValue = 1.0; // Not restorable. @override - void restoreState(RestorationBucket oldBucket, bool initialRestore) { + void restoreState(RestorationBucket? oldBucket, bool initialRestore) { registerForRestoration(stringValue, 'string'); registerForRestoration(intValue, 'int'); } @@ -109,5 +107,5 @@ class _RestorableWidgetState extends State<_RestorableWidget> with RestorationMi } @override - String get restorationId => widget.restorationId; + String? get restorationId => widget.restorationId; } diff --git a/packages/flutter_test/test/stack_manipulation_test.dart b/packages/flutter_test/test/stack_manipulation_test.dart index 91a1b6cf9fd..a484026ba5e 100644 --- a/packages/flutter_test/test/stack_manipulation_test.dart +++ b/packages/flutter_test/test/stack_manipulation_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'package:flutter/foundation.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -22,7 +20,7 @@ void main() { } try { - throw null; + throw Object(); } catch (e, stack) { final List information = []; expect(reportExpectCall(stack, information), 0); diff --git a/packages/flutter_test/test/test_async_utils_test.dart b/packages/flutter_test/test/test_async_utils_test.dart index 236a618ec01..c381e6a3626 100644 --- a/packages/flutter_test/test/test_async_utils_test.dart +++ b/packages/flutter_test/test/test_async_utils_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -18,17 +16,17 @@ import 'package:test_api/test_api.dart' as real_test show expect; // of this test is to see how we handle leaking APIs. class TestAPI { - Future testGuard1() { - return TestAsyncUtils.guard(() async { return null; }); + Future testGuard1() { + return TestAsyncUtils.guard(() async { return null; }); } - Future testGuard2() { - return TestAsyncUtils.guard(() async { return null; }); + Future testGuard2() { + return TestAsyncUtils.guard(() async { return null; }); } } class TestAPISubclass extends TestAPI { - Future testGuard3() { - return TestAsyncUtils.guard(() async { return null; }); + Future testGuard3() { + return TestAsyncUtils.guard(() async { return null; }); } } @@ -41,7 +39,7 @@ Future _guardedThrower() { void main() { test('TestAsyncUtils - one class', () async { final TestAPI testAPI = TestAPI(); - Future f1, f2; + Future? f1, f2; f1 = testAPI.testGuard1(); try { f2 = testAPI.testGuard2(); @@ -63,7 +61,7 @@ void main() { test('TestAsyncUtils - two classes, all callers in superclass', () async { final TestAPI testAPI = TestAPISubclass(); - Future f1, f2; + Future? f1, f2; f1 = testAPI.testGuard1(); try { f2 = testAPI.testGuard2(); @@ -85,7 +83,7 @@ void main() { test('TestAsyncUtils - two classes, mixed callers', () async { final TestAPISubclass testAPI = TestAPISubclass(); - Future f1, f2; + Future? f1, f2; f1 = testAPI.testGuard1(); try { f2 = testAPI.testGuard3(); @@ -107,7 +105,7 @@ void main() { test('TestAsyncUtils - expect() catches pending async work', () async { final TestAPI testAPI = TestAPISubclass(); - Future f1; + Future? f1; f1 = testAPI.testGuard1(); try { flutter_test.expect(0, 0); @@ -128,7 +126,7 @@ void main() { }); testWidgets('TestAsyncUtils - expect() catches pending async work', (WidgetTester tester) async { - Future f1, f2; + Future? f1, f2; try { f1 = tester.pump(); f2 = tester.pump(); @@ -170,7 +168,7 @@ void main() { }); testWidgets('TestAsyncUtils - expect() catches pending async work', (WidgetTester tester) async { - Future f1; + Future? f1; try { f1 = tester.pump(); TestAsyncUtils.verifyAllScopesClosed(); @@ -195,7 +193,7 @@ void main() { }); testWidgets('TestAsyncUtils - expect() catches pending async work', (WidgetTester tester) async { - Future f1; + Future? f1; try { f1 = tester.pump(); TestAsyncUtils.verifyAllScopesClosed(); diff --git a/packages/flutter_test/test/test_config/child_directory/config_test.dart b/packages/flutter_test/test/test_config/child_directory/config_test.dart index 1064f9cf4ad..5b289e9c4ec 100644 --- a/packages/flutter_test/test/test_config/child_directory/config_test.dart +++ b/packages/flutter_test/test/test_config/child_directory/config_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import '../config_test_utils.dart'; void main() { diff --git a/packages/flutter_test/test/test_config/child_directory/grandchild_directory/config_test.dart b/packages/flutter_test/test/test_config/child_directory/grandchild_directory/config_test.dart index 805fe9d27f2..5035022478a 100644 --- a/packages/flutter_test/test/test_config/child_directory/grandchild_directory/config_test.dart +++ b/packages/flutter_test/test/test_config/child_directory/grandchild_directory/config_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import '../../config_test_utils.dart'; void main() { diff --git a/packages/flutter_test/test/test_config/config_test.dart b/packages/flutter_test/test/test_config/config_test.dart index ebb7d6af28e..dc2c636b38a 100644 --- a/packages/flutter_test/test/test_config/config_test.dart +++ b/packages/flutter_test/test/test_config/config_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'config_test_utils.dart'; void main() { 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 7bb611889e0..6c1723933ff 100644 --- a/packages/flutter_test/test/test_config/config_test_utils.dart +++ b/packages/flutter_test/test/test_config/config_test_utils.dart @@ -2,15 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; import 'package:flutter_test/flutter_test.dart'; void testConfig( String description, - String expectedStringValue, { + String? expectedStringValue, { Map otherExpectedValues = const {int: isNull}, }) { final String actualStringValue = Zone.current[String] as String; diff --git a/packages/flutter_test/test/test_config/flutter_test_config.dart b/packages/flutter_test/test/test_config/flutter_test_config.dart index d7d0691ed7f..f9ba79eb418 100644 --- a/packages/flutter_test/test/test_config/flutter_test_config.dart +++ b/packages/flutter_test/test/test_config/flutter_test_config.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; Future main(FutureOr testMain()) async { diff --git a/packages/flutter_test/test/test_config/nested_config/config_test.dart b/packages/flutter_test/test/test_config/nested_config/config_test.dart index 061e1e66c65..985f5e41d71 100644 --- a/packages/flutter_test/test/test_config/nested_config/config_test.dart +++ b/packages/flutter_test/test/test_config/nested_config/config_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import '../config_test_utils.dart'; void main() { diff --git a/packages/flutter_test/test/test_config/nested_config/flutter_test_config.dart b/packages/flutter_test/test/test_config/nested_config/flutter_test_config.dart index 55f210be974..d0648112d73 100644 --- a/packages/flutter_test/test/test_config/nested_config/flutter_test_config.dart +++ b/packages/flutter_test/test/test_config/nested_config/flutter_test_config.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; Future main(FutureOr testMain()) async { diff --git a/packages/flutter_test/test/test_config/project_root/config_test.dart b/packages/flutter_test/test/test_config/project_root/config_test.dart index 0f7282f7a02..001c2b82125 100644 --- a/packages/flutter_test/test/test_config/project_root/config_test.dart +++ b/packages/flutter_test/test/test_config/project_root/config_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import '../config_test_utils.dart'; void main() { diff --git a/packages/flutter_test/test/test_text_input_test.dart b/packages/flutter_test/test/test_text_input_test.dart index 5d08dd5300c..dfcc6024c2c 100644 --- a/packages/flutter_test/test/test_text_input_test.dart +++ b/packages/flutter_test/test/test_text_input_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter_test/test/widget_tester_test.dart b/packages/flutter_test/test/widget_tester_test.dart index c6120e7ac54..8a4e94f4ca1 100644 --- a/packages/flutter_test/test/widget_tester_test.dart +++ b/packages/flutter_test/test/widget_tester_test.dart @@ -2,8 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:async'; import 'dart:io'; import 'dart:ui'; @@ -30,7 +28,7 @@ void main() { testWidgets('completes when matcher completes', (WidgetTester tester) async { final Completer completer = Completer(); final Future future = expectLater(null, FakeMatcher(completer)); - String result; + String? result; future.then((void value) { result = '123'; }); @@ -62,7 +60,7 @@ void main() { }); testWidgets('fails with a descriptive message', (WidgetTester tester) async { - TestFailure failure; + late TestFailure failure; try { expect(find.text('foo', skipOffstage: false), findsOneWidget); } on TestFailure catch (e) { @@ -85,7 +83,7 @@ void main() { testWidgets('fails with a descriptive message', (WidgetTester tester) async { await tester.pumpWidget(const Text('foo', textDirection: TextDirection.ltr)); - TestFailure failure; + late TestFailure failure; try { expect(find.text('foo', skipOffstage: false), findsNothing); } on TestFailure catch (e) { @@ -103,7 +101,7 @@ void main() { testWidgets('fails with a descriptive message when skipping', (WidgetTester tester) async { await tester.pumpWidget(const Text('foo', textDirection: TextDirection.ltr)); - TestFailure failure; + late TestFailure failure; try { expect(find.text('foo'), findsNothing); } on TestFailure catch (e) { @@ -156,13 +154,13 @@ void main() { testWidgets('pumpFrames', (WidgetTester tester) async { final List logPaints = []; - int initial; + int? initial; final Widget target = _AlwaysAnimating( onPaint: () { - final int current = SchedulerBinding.instance.currentFrameTimeStamp.inMicroseconds; + final int current = SchedulerBinding.instance!.currentFrameTimeStamp.inMicroseconds; initial ??= current; - logPaints.add(current - initial); + logPaints.add(current - initial!); }, ); @@ -182,7 +180,7 @@ void main() { await tester.pumpWidget(const Text('foo', textDirection: TextDirection.ltr)); const String customDescription = 'custom description'; - TestFailure failure; + late TestFailure failure; try { expect(find.byElementPredicate((_) => false, description: customDescription), findsOneWidget); } on TestFailure catch (e) { @@ -199,7 +197,7 @@ void main() { await tester.pumpWidget(const Text('foo', textDirection: TextDirection.ltr)); const String customDescription = 'custom description'; - TestFailure failure; + late TestFailure failure; try { expect(find.byWidgetPredicate((_) => false, description: customDescription), findsOneWidget); } on TestFailure catch (e) { @@ -250,7 +248,7 @@ void main() { ], )); - TestFailure failure; + late TestFailure failure; try { expect(find.descendant( of: find.widgetWithText(Column, 'foo'), @@ -312,7 +310,7 @@ void main() { ], )); - TestFailure failure; + late TestFailure failure; try { expect(find.ancestor( of: find.text('bar'), @@ -554,7 +552,7 @@ void main() { group('runAsync', () { testWidgets('works with no async calls', (WidgetTester tester) async { - String value; + String? value; await tester.runAsync(() async { value = '123'; }); @@ -574,14 +572,14 @@ void main() { }); testWidgets('propagates return values', (WidgetTester tester) async { - final String value = await tester.runAsync(() async { + final String? value = await tester.runAsync(() async { return '123'; }); expect(value, '123'); }); testWidgets('reports errors via framework', (WidgetTester tester) async { - final String value = await tester.runAsync(() async { + final String? value = await tester.runAsync(() async { throw ArgumentError(); }); expect(value, isNull); @@ -630,7 +628,7 @@ void main() { }); testWidgets('verifyTickersWereDisposed control test', (WidgetTester tester) async { - FlutterError error; + late FlutterError error; final Ticker ticker = tester.createTicker((Duration duration) {}); ticker.start(); try { @@ -685,7 +683,7 @@ void main() { group('TargetPlatformVariant', () { int numberOfVariationsRun = 0; - TargetPlatform origTargetPlatform; + TargetPlatform? origTargetPlatform; setUpAll((){ origTargetPlatform = debugDefaultTargetPlatformOverride; @@ -717,7 +715,7 @@ void main() { }); group('Pending timer', () { - TestExceptionReporter currentExceptionReporter; + late TestExceptionReporter currentExceptionReporter; setUp(() { currentExceptionReporter = reportTestException; }); @@ -727,7 +725,7 @@ void main() { }); test('Throws assertion message without code', () async { - FlutterErrorDetails flutterErrorDetails; + late FlutterErrorDetails flutterErrorDetails; reportTestException = (FlutterErrorDetails details, String testDescription) { flutterErrorDetails = details; }; @@ -738,8 +736,8 @@ void main() { expect(timer.isActive, true); }, () {}); - expect(flutterErrorDetails?.exception, isA()); - expect(flutterErrorDetails?.exception?.message, 'A Timer is still pending even after the widget tree was disposed.'); + expect(flutterErrorDetails.exception, isA()); + expect(flutterErrorDetails.exception!.message, 'A Timer is still pending even after the widget tree was disposed.'); }); }); } @@ -750,8 +748,8 @@ class FakeMatcher extends AsyncMatcher { final Completer completer; @override - Future matchAsync(dynamic object) { - return completer.future.then((void value) { + Future matchAsync(dynamic object) { + return completer.future.then((void value) { return object?.toString(); }); } @@ -761,14 +759,14 @@ class FakeMatcher extends AsyncMatcher { } class _SingleTickerTest extends StatefulWidget { - const _SingleTickerTest({Key key}) : super(key: key); + const _SingleTickerTest({Key? key}) : super(key: key); @override _SingleTickerTestState createState() => _SingleTickerTestState(); } class _SingleTickerTestState extends State<_SingleTickerTest> with SingleTickerProviderStateMixin { - AnimationController controller; + late AnimationController controller; @override void initState() { @@ -788,10 +786,10 @@ class _SingleTickerTestState extends State<_SingleTickerTest> with SingleTickerP class _AlwaysAnimating extends StatefulWidget { const _AlwaysAnimating({ this.child, - this.onPaint, + required this.onPaint, }); - final Widget child; + final Widget? child; final VoidCallback onPaint; @override @@ -799,7 +797,7 @@ class _AlwaysAnimating extends StatefulWidget { } class _AlwaysAnimatingState extends State<_AlwaysAnimating> with SingleTickerProviderStateMixin { - AnimationController _controller; + late AnimationController _controller; @override void initState() { @@ -821,7 +819,7 @@ class _AlwaysAnimatingState extends State<_AlwaysAnimating> with SingleTickerPro Widget build(BuildContext context) { return AnimatedBuilder( animation: _controller.view, - builder: (BuildContext context, Widget child) { + builder: (BuildContext context, Widget? child) { return CustomPaint( painter: _AlwaysRepaint(widget.onPaint), child: widget.child, diff --git a/packages/flutter_test/test/window_test.dart b/packages/flutter_test/test/window_test.dart index cb162c342ca..bfde8d88b7c 100644 --- a/packages/flutter_test/test/window_test.dart +++ b/packages/flutter_test/test/window_test.dart @@ -2,18 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.9 - import 'dart:ui' as ui show window; import 'dart:ui' show Size, Locale, WindowPadding, AccessibilityFeatures, Brightness; import 'package:flutter/widgets.dart' show WidgetsBinding; import 'package:flutter_test/flutter_test.dart'; -import 'package:meta/meta.dart'; void main() { test('TestWindow can handle new methods without breaking', () { - final dynamic testWindow = TestWindow(window: ui.window); + final dynamic testWindow = TestWindow(window: ui.window); // ignore: unnecessary_nullable_for_final_variable_declarations expect(testWindow.someNewProperty, null); }); @@ -23,7 +20,7 @@ void main() { realValue: ui.window.devicePixelRatio, fakeValue: 2.5, propertyRetriever: () { - return WidgetsBinding.instance.window.devicePixelRatio; + return WidgetsBinding.instance!.window.devicePixelRatio; }, propertyFaker: (TestWidgetsFlutterBinding binding, double fakeValue) { binding.window.devicePixelRatioTestValue = fakeValue; @@ -37,7 +34,7 @@ void main() { realValue: ui.window.physicalSize, fakeValue: const Size(50, 50), propertyRetriever: () { - return WidgetsBinding.instance.window.physicalSize; + return WidgetsBinding.instance!.window.physicalSize; }, propertyFaker: (TestWidgetsFlutterBinding binding, Size fakeValue) { binding.window.physicalSizeTestValue = fakeValue; @@ -51,7 +48,7 @@ void main() { realValue: ui.window.viewInsets, fakeValue: const FakeWindowPadding(), propertyRetriever: () { - return WidgetsBinding.instance.window.viewInsets; + return WidgetsBinding.instance!.window.viewInsets; }, propertyFaker: (TestWidgetsFlutterBinding binding, WindowPadding fakeValue) { binding.window.viewInsetsTestValue = fakeValue; @@ -65,7 +62,7 @@ void main() { realValue: ui.window.padding, fakeValue: const FakeWindowPadding(), propertyRetriever: () { - return WidgetsBinding.instance.window.padding; + return WidgetsBinding.instance!.window.padding; }, propertyFaker: (TestWidgetsFlutterBinding binding, WindowPadding fakeValue) { binding.window.paddingTestValue = fakeValue; @@ -79,7 +76,7 @@ void main() { realValue: ui.window.locale, fakeValue: const Locale('fake_language_code'), propertyRetriever: () { - return WidgetsBinding.instance.window.locale; + return WidgetsBinding.instance!.window.locale; }, propertyFaker: (TestWidgetsFlutterBinding binding, Locale fakeValue) { binding.window.localeTestValue = fakeValue; @@ -93,7 +90,7 @@ void main() { realValue: ui.window.locales, fakeValue: [const Locale('fake_language_code')], propertyRetriever: () { - return WidgetsBinding.instance.window.locales; + return WidgetsBinding.instance!.window.locales; }, propertyFaker: (TestWidgetsFlutterBinding binding, List fakeValue) { binding.window.localesTestValue = fakeValue; @@ -107,7 +104,7 @@ void main() { realValue: ui.window.textScaleFactor, fakeValue: 2.5, propertyRetriever: () { - return WidgetsBinding.instance.window.textScaleFactor; + return WidgetsBinding.instance!.window.textScaleFactor; }, propertyFaker: (TestWidgetsFlutterBinding binding, double fakeValue) { binding.window.textScaleFactorTestValue = fakeValue; @@ -121,7 +118,7 @@ void main() { realValue: ui.window.alwaysUse24HourFormat, fakeValue: !ui.window.alwaysUse24HourFormat, propertyRetriever: () { - return WidgetsBinding.instance.window.alwaysUse24HourFormat; + return WidgetsBinding.instance!.window.alwaysUse24HourFormat; }, propertyFaker: (TestWidgetsFlutterBinding binding, bool fakeValue) { binding.window.alwaysUse24HourFormatTestValue = fakeValue; @@ -135,7 +132,7 @@ void main() { realValue: ui.window.defaultRouteName, fakeValue: 'fake_route', propertyRetriever: () { - return WidgetsBinding.instance.window.defaultRouteName; + return WidgetsBinding.instance!.window.defaultRouteName; }, propertyFaker: (TestWidgetsFlutterBinding binding, String fakeValue) { binding.window.defaultRouteNameTestValue = fakeValue; @@ -149,7 +146,7 @@ void main() { realValue: ui.window.accessibilityFeatures, fakeValue: const FakeAccessibilityFeatures(), propertyRetriever: () { - return WidgetsBinding.instance.window.accessibilityFeatures; + return WidgetsBinding.instance!.window.accessibilityFeatures; }, propertyFaker: (TestWidgetsFlutterBinding binding, AccessibilityFeatures fakeValue) { binding.window.accessibilityFeaturesTestValue = fakeValue; @@ -163,7 +160,7 @@ void main() { realValue: Brightness.light, fakeValue: Brightness.dark, propertyRetriever: () { - return WidgetsBinding.instance.window.platformBrightness; + return WidgetsBinding.instance!.window.platformBrightness; }, propertyFaker: (TestWidgetsFlutterBinding binding, Brightness fakeValue) { binding.window.platformBrightnessTestValue = fakeValue; @@ -184,20 +181,20 @@ void main() { testWindow.clearAllTestValues(); // Verify that the window once again reports real property values. - expect(WidgetsBinding.instance.window.devicePixelRatio, originalDevicePixelRatio); - expect(WidgetsBinding.instance.window.textScaleFactor, originalTextScaleFactor); + expect(WidgetsBinding.instance!.window.devicePixelRatio, originalDevicePixelRatio); + expect(WidgetsBinding.instance!.window.textScaleFactor, originalTextScaleFactor); }); } void verifyThatTestWindowCanFakeProperty({ - @required WidgetTester tester, - @required WindowPropertyType realValue, - @required WindowPropertyType fakeValue, - @required WindowPropertyType Function() propertyRetriever, - @required Function(TestWidgetsFlutterBinding, WindowPropertyType fakeValue) propertyFaker, + required WidgetTester tester, + required WindowPropertyType? realValue, + required WindowPropertyType fakeValue, + required WindowPropertyType? Function() propertyRetriever, + required Function(TestWidgetsFlutterBinding, WindowPropertyType fakeValue) propertyFaker, }) { - WindowPropertyType propertyBeforeFaking; - WindowPropertyType propertyAfterFaking; + WindowPropertyType? propertyBeforeFaking; + WindowPropertyType? propertyAfterFaking; propertyBeforeFaking = propertyRetriever();