diff --git a/packages/flutter/test/cupertino/text_field_restoration_test.dart b/packages/flutter/test/cupertino/text_field_restoration_test.dart index 65374564a4d..7a7d4afbd4d 100644 --- a/packages/flutter/test/cupertino/text_field_restoration_test.dart +++ b/packages/flutter/test/cupertino/text_field_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.8 - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; @@ -75,7 +73,7 @@ Future restoreAndVerify(WidgetTester tester) async { } class TestWidget extends StatefulWidget { - const TestWidget({Key key, this.useExternal = false}) : super(key: key); + const TestWidget({Key? key, this.useExternal = false}) : super(key: key); final bool useExternal; @@ -90,7 +88,7 @@ class TestWidgetState extends State with RestorationMixin { String get restorationId => 'widget'; @override - void restoreState(RestorationBucket oldBucket, bool initialRestore) { + void restoreState(RestorationBucket? oldBucket, bool initialRestore) { registerForRestoration(controller, 'controller'); } diff --git a/packages/flutter/test/cupertino/text_field_test.dart b/packages/flutter/test/cupertino/text_field_test.dart index 46e4162d2c4..9d3b65174e9 100644 --- a/packages/flutter/test/cupertino/text_field_test.dart +++ b/packages/flutter/test/cupertino/text_field_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.8 - import 'dart:ui' as ui show BoxHeightStyle, BoxWidthStyle, Color; import 'package:flutter/cupertino.dart'; @@ -25,7 +23,7 @@ class MockClipboard { case 'Clipboard.getData': return _clipboardData; case 'Clipboard.setData': - _clipboardData = methodCall.arguments; + _clipboardData = methodCall.arguments! as Object; break; } } @@ -40,23 +38,23 @@ class PathBoundsMatcher extends Matcher { this.bottomMatcher, }) : super(); - final Matcher rectMatcher; - final Matcher topMatcher; - final Matcher leftMatcher; - final Matcher rightMatcher; - final Matcher bottomMatcher; + final Matcher? rectMatcher; + final Matcher? topMatcher; + final Matcher? leftMatcher; + final Matcher? rightMatcher; + final Matcher? bottomMatcher; @override bool matches(covariant Path item, Map matchState) { final Rect bounds = item.getBounds(); - final List matchers = [rectMatcher, topMatcher, leftMatcher, rightMatcher, bottomMatcher]; + final List matchers = [rectMatcher, topMatcher, leftMatcher, rightMatcher, bottomMatcher]; final List values = [bounds, bounds.top, bounds.left, bounds.right, bounds.bottom]; final Map failedMatcher = {}; for(int idx = 0; idx < matchers.length; idx++) { if (!(matchers[idx]?.matches(values[idx], matchState) != false)) { - failedMatcher[matchers[idx]] = values[idx]; + failedMatcher[matchers[idx]!] = values[idx]; } } @@ -94,8 +92,8 @@ class PathPointsMatcher extends Matcher { @override bool matches(covariant Path item, Map matchState) { - final Offset notIncluded = includes.firstWhere((Offset offset) => !item.contains(offset), orElse: () => null); - final Offset notExcluded = excludes.firstWhere(item.contains, orElse: () => null); + final Offset? notIncluded = includes.cast().firstWhere((Offset? offset) => !item.contains(offset!), orElse: () => null); + final Offset? notExcluded = excludes.cast().firstWhere((Offset? offset) => item.contains(offset!), orElse: () => null); matchState['notIncluded'] = notIncluded; matchState['notExcluded'] = notExcluded; @@ -107,8 +105,8 @@ class PathPointsMatcher extends Matcher { @override Description describeMismatch(covariant Path item, Description mismatchDescription, Map matchState, bool verbose) { - final Offset notIncluded = matchState['notIncluded'] as Offset; - final Offset notExcluded = matchState['notExcluded'] as Offset; + final Offset? notIncluded = matchState['notIncluded'] as Offset?; + final Offset? notExcluded = matchState['notExcluded'] as Offset?; final Description desc = super.describeMismatch(item, mismatchDescription, matchState, verbose); if ((notExcluded ?? notIncluded) != null) { @@ -136,7 +134,7 @@ void main() { final RenderObject root = tester.renderObject(find.byType(EditableText)); expect(root, isNotNull); - RenderEditable renderEditable; + RenderEditable? renderEditable; void recursiveFinder(RenderObject child) { if (child is RenderEditable) { renderEditable = child; @@ -146,7 +144,7 @@ void main() { } root.visitChildren(recursiveFinder); expect(renderEditable, isNotNull); - return renderEditable; + return renderEditable!; } List globalize(Iterable points, RenderBox box) { @@ -344,7 +342,7 @@ void main() { BorderRadius.circular(5), ); expect( - decoration.border.bottom.color.value, + decoration.border!.bottom.color.value, 0x33000000, ); @@ -370,7 +368,7 @@ void main() { BorderRadius.circular(5), ); expect( - decoration.border.bottom.color.value, + decoration.border!.bottom.color.value, 0x33FFFFFF, ); }, @@ -444,24 +442,24 @@ void main() { final EditableTextState editableTextState = tester.firstState(find.byType(EditableText)); final RenderEditable renderEditable = editableTextState.renderEditable; - expect(renderEditable.cursorColor.alpha, 255); + expect(renderEditable.cursorColor!.alpha, 255); await tester.pump(const Duration(milliseconds: 100)); await tester.pump(const Duration(milliseconds: 400)); - expect(renderEditable.cursorColor.alpha, 255); + expect(renderEditable.cursorColor!.alpha, 255); await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 100)); - expect(renderEditable.cursorColor.alpha, 110); + expect(renderEditable.cursorColor!.alpha, 110); await tester.pump(const Duration(milliseconds: 100)); - expect(renderEditable.cursorColor.alpha, 16); + expect(renderEditable.cursorColor!.alpha, 16); await tester.pump(const Duration(milliseconds: 50)); - expect(renderEditable.cursorColor.alpha, 0); + expect(renderEditable.cursorColor!.alpha, 0); }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); testWidgets('Cursor radius is 2.0', (WidgetTester tester) async { @@ -528,7 +526,7 @@ void main() { await expectLater( find.byKey(const ValueKey(1)), matchesGoldenFile( - 'text_field_cursor_test.cupertino_${describeEnum(debugDefaultTargetPlatformOverride).toLowerCase()}.1.png', + 'text_field_cursor_test.cupertino_${describeEnum(debugDefaultTargetPlatformOverride!).toLowerCase()}.1.png', ), ); }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); @@ -599,7 +597,7 @@ void main() { ); final Text placeholder = tester.widget(find.text('placeholder')); - expect(placeholder.style.color.value, CupertinoColors.placeholderText.darkColor.value); + expect(placeholder.style!.color!.value, CupertinoColors.placeholderText.darkColor.value); }); testWidgets( @@ -616,7 +614,7 @@ void main() { ); final Text placeholder = tester.widget(find.text('placeholder')); - expect(placeholder.style.color.value, CupertinoColors.placeholderText.color.value); + expect(placeholder.style!.color!.value, CupertinoColors.placeholderText.color.value); await tester.enterText(find.byType(CupertinoTextField), 'input'); await tester.pump(); @@ -646,8 +644,8 @@ void main() { ); final Text placeholder = tester.widget(find.text('placeholder')); - expect(placeholder.style.color, const Color(0xAAFFFFFF)); - expect(placeholder.style.fontWeight, FontWeight.w600); + expect(placeholder.style!.color, const Color(0xAAFFFFFF)); + expect(placeholder.style!.fontWeight, FontWeight.w600); await tester.enterText(find.byType(CupertinoTextField), 'input'); await tester.pump(); @@ -1285,10 +1283,10 @@ void main() { await tester.pump(const Duration(milliseconds: 200)); Text text = tester.widget(find.text('Paste')); - expect(text.style.color, CupertinoColors.white); - expect(text.style.fontSize, 14); - expect(text.style.letterSpacing, -0.15); - expect(text.style.fontWeight, FontWeight.w400); + expect(text.style!.color, CupertinoColors.white); + expect(text.style!.fontSize, 14); + expect(text.style!.letterSpacing, -0.15); + expect(text.style!.fontWeight, FontWeight.w400); // Change the theme. await tester.pumpWidget( @@ -1317,10 +1315,10 @@ void main() { text = tester.widget(find.text('Paste')); // The toolbar buttons' text are still the same style. - expect(text.style.color, CupertinoColors.white); - expect(text.style.fontSize, 14); - expect(text.style.letterSpacing, -0.15); - expect(text.style.fontWeight, FontWeight.w400); + expect(text.style!.color, CupertinoColors.white); + expect(text.style!.fontSize, 14); + expect(text.style!.letterSpacing, -0.15); + expect(text.style!.fontWeight, FontWeight.w400); }); @@ -2455,8 +2453,8 @@ void main() { await tester.pump(); final EditableTextState editableText = tester.state(find.byType(EditableText)); - expect(editableText.selectionOverlay.handlesAreVisible, isFalse); - expect(editableText.selectionOverlay.toolbarIsVisible, isFalse); + expect(editableText.selectionOverlay!.handlesAreVisible, isFalse); + expect(editableText.selectionOverlay!.toolbarIsVisible, isFalse); }); testWidgets('Long press shows toolbar but not handles', (WidgetTester tester) async { @@ -2479,8 +2477,8 @@ void main() { expect(controller.selection.isCollapsed, isTrue); final EditableTextState editableText = tester.state(find.byType(EditableText)); - expect(editableText.selectionOverlay.handlesAreVisible, isFalse); - expect(editableText.selectionOverlay.toolbarIsVisible, isTrue); + expect(editableText.selectionOverlay!.handlesAreVisible, isFalse); + expect(editableText.selectionOverlay!.toolbarIsVisible, isTrue); }); testWidgets( @@ -2507,8 +2505,8 @@ void main() { await tester.pump(); final EditableTextState editableText = tester.state(find.byType(EditableText)); - expect(editableText.selectionOverlay.handlesAreVisible, isTrue); - expect(editableText.selectionOverlay.toolbarIsVisible, isTrue); + expect(editableText.selectionOverlay!.handlesAreVisible, isTrue); + expect(editableText.selectionOverlay!.toolbarIsVisible, isTrue); }, ); @@ -2536,8 +2534,8 @@ void main() { await tester.pump(); final EditableTextState editableText = tester.state(find.byType(EditableText)); - expect(editableText.selectionOverlay.handlesAreVisible, isFalse); - expect(editableText.selectionOverlay.toolbarIsVisible, isTrue); + expect(editableText.selectionOverlay!.handlesAreVisible, isFalse); + expect(editableText.selectionOverlay!.toolbarIsVisible, isTrue); }, ); @@ -2568,8 +2566,8 @@ void main() { await tester.pump(); final EditableTextState editableText = tester.state(find.byType(EditableText)); - expect(editableText.selectionOverlay.toolbarIsVisible, isFalse); - expect(editableText.selectionOverlay.handlesAreVisible, isFalse); + expect(editableText.selectionOverlay!.toolbarIsVisible, isFalse); + expect(editableText.selectionOverlay!.handlesAreVisible, isFalse); }, ); @@ -2605,8 +2603,8 @@ void main() { await gesture.up(); await tester.pump(); - expect(editableText.selectionOverlay.toolbarIsVisible, isFalse); - expect(editableText.selectionOverlay.handlesAreVisible, isFalse); + expect(editableText.selectionOverlay!.toolbarIsVisible, isFalse); + expect(editableText.selectionOverlay!.handlesAreVisible, isFalse); final Offset hPos = textOffsetToPosition(tester, 9); // Position of 'h'. @@ -2620,8 +2618,8 @@ void main() { await gesture.up(); await tester.pump(); - expect(editableText.selectionOverlay.handlesAreVisible, isFalse); - expect(editableText.selectionOverlay.toolbarIsVisible, isFalse); + expect(editableText.selectionOverlay!.handlesAreVisible, isFalse); + expect(editableText.selectionOverlay!.toolbarIsVisible, isFalse); }, ); @@ -2731,7 +2729,7 @@ void main() { ).decoration as BoxDecoration; expect( - decoration.border.bottom.color.value, + decoration.border!.bottom.color.value, 0x33FFFFFF, ); @@ -2741,7 +2739,7 @@ void main() { expect( tester.renderObject( find.byElementPredicate((Element element) => element.renderObject is RenderEditable) - ).text.style.color, + ).text!.style!.color, isSameColorAs(CupertinoColors.white), ); }, @@ -3130,7 +3128,7 @@ void main() { await tester.pumpAndSettle(); // -1 because we want to reach the end of the line, not the start of a new line. - bottomLeftSelectionPosition = textOffsetToBottomLeftPosition(tester, state.renderEditable.selection.baseOffset - 1); + bottomLeftSelectionPosition = textOffsetToBottomLeftPosition(tester, state.renderEditable.selection!.baseOffset - 1); expect( find.byType(CupertinoTextSelectionToolbar), @@ -3190,7 +3188,7 @@ void main() { expect(state.showToolbar(), true); await tester.pumpAndSettle(); - bottomLeftSelectionPosition = textOffsetToBottomLeftPosition(tester, state.renderEditable.selection.baseOffset); + bottomLeftSelectionPosition = textOffsetToBottomLeftPosition(tester, state.renderEditable.selection!.baseOffset); expect( find.byType(CupertinoTextSelectionToolbar), diff --git a/packages/flutter/test/cupertino/text_selection_test.dart b/packages/flutter/test/cupertino/text_selection_test.dart index a7ab2efcbe5..dc7087765da 100644 --- a/packages/flutter/test/cupertino/text_selection_test.dart +++ b/packages/flutter/test/cupertino/text_selection_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.8 - import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; @@ -23,7 +21,7 @@ class MockClipboard { case 'Clipboard.getData': return _clipboardData; case 'Clipboard.setData': - _clipboardData = methodCall.arguments; + _clipboardData = methodCall.arguments! as Object; break; } } @@ -80,14 +78,14 @@ void main() { ), ); // Disabled buttons have no opacity change when pressed. - return button.pressedOpacity < 1.0; + return button.pressedOpacity! < 1.0; } group('canSelectAll', () { Widget createEditableText({ - Key key, - String text, - TextSelection selection, + Key? key, + String? text, + TextSelection? selection, }) { final TextEditingController controller = TextEditingController(text: text) ..selection = selection ?? const TextSelection.collapsed(offset: -1); @@ -106,7 +104,7 @@ void main() { testWidgets('should return false when there is no text', (WidgetTester tester) async { final GlobalKey key = GlobalKey(); await tester.pumpWidget(createEditableText(key: key)); - expect(cupertinoTextSelectionControls.canSelectAll(key.currentState), false); + expect(cupertinoTextSelectionControls.canSelectAll(key.currentState!), false); }); testWidgets('should return true when there is text and collapsed selection', (WidgetTester tester) async { @@ -115,7 +113,7 @@ void main() { key: key, text: '123', )); - expect(cupertinoTextSelectionControls.canSelectAll(key.currentState), true); + expect(cupertinoTextSelectionControls.canSelectAll(key.currentState!), true); }); testWidgets('should return false when there is text and partial uncollapsed selection', (WidgetTester tester) async { @@ -125,7 +123,7 @@ void main() { text: '123', selection: const TextSelection(baseOffset: 1, extentOffset: 2), )); - expect(cupertinoTextSelectionControls.canSelectAll(key.currentState), false); + expect(cupertinoTextSelectionControls.canSelectAll(key.currentState!), false); }); testWidgets('should return false when there is text and full selection', (WidgetTester tester) async { @@ -135,7 +133,7 @@ void main() { text: '123', selection: const TextSelection(baseOffset: 0, extentOffset: 3), )); - expect(cupertinoTextSelectionControls.canSelectAll(key.currentState), false); + expect(cupertinoTextSelectionControls.canSelectAll(key.currentState!), false); }); }); diff --git a/packages/flutter/test/cupertino/theme_test.dart b/packages/flutter/test/cupertino/theme_test.dart index ae1beb3c625..6d33b794459 100644 --- a/packages/flutter/test/cupertino/theme_test.dart +++ b/packages/flutter/test/cupertino/theme_test.dart @@ -2,16 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:flutter/foundation.dart'; import 'package:flutter/painting.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_test/flutter_test.dart'; -int buildCount; -CupertinoThemeData actualTheme; -IconThemeData actualIconTheme; +int buildCount = 0; +CupertinoThemeData? actualTheme; +IconThemeData? actualIconTheme; final Widget singletonThemeSubtree = Builder( builder: (BuildContext context) { @@ -29,7 +27,7 @@ Future testTheme(WidgetTester tester, CupertinoThemeData the child: singletonThemeSubtree, ), ); - return actualTheme; + return actualTheme!; } Future testIconTheme(WidgetTester tester, CupertinoThemeData theme) async { @@ -39,13 +37,14 @@ Future testIconTheme(WidgetTester tester, CupertinoThemeData them child: singletonThemeSubtree, ), ); - return actualIconTheme; + return actualIconTheme!; } void main() { setUp(() { buildCount = 0; actualTheme = null; + actualIconTheme = null; }); testWidgets('Default theme has defaults', (WidgetTester tester) async { @@ -150,7 +149,7 @@ void main() { final Color darkColor = (await testIconTheme( tester, themeData.copyWith(brightness: Brightness.dark), - )).color; + )).color!; expect(darkColor, isSameColorAs(primaryColor.darkColor)); }); @@ -207,8 +206,8 @@ void main() { ); }); - Brightness currentBrightness; - void colorMatches(Color componentColor, CupertinoDynamicColor expectedDynamicColor) { + late Brightness currentBrightness; + void colorMatches(Color? componentColor, CupertinoDynamicColor expectedDynamicColor) { switch (currentBrightness) { case Brightness.light: expect(componentColor, isSameColorAs(expectedDynamicColor.color)); diff --git a/packages/flutter/test/flutter_test_alternative.dart b/packages/flutter/test/flutter_test_alternative.dart index 5eef49a04be..549794c6406 100644 --- a/packages/flutter/test/flutter_test_alternative.dart +++ b/packages/flutter/test/flutter_test_alternative.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.8 - // Defines a 'package:test' shim. // TODO(ianh): Remove this file once https://github.com/dart-lang/matcher/issues/98 is fixed diff --git a/packages/flutter/test/flutter_test_config.dart b/packages/flutter/test/flutter_test_config.dart index 13680baf7ca..c75a69ec2fc 100644 --- a/packages/flutter/test/flutter_test_config.dart +++ b/packages/flutter/test/flutter_test_config.dart @@ -2,6 +2,4 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - export 'package:flutter_goldens/flutter_goldens.dart' show main; diff --git a/packages/flutter/test/gestures/gesture_binding_resample_event_on_widget_test.dart b/packages/flutter/test/gestures/gesture_binding_resample_event_on_widget_test.dart index 1e46dbed0e9..8b2039283e7 100644 --- a/packages/flutter/test/gestures/gesture_binding_resample_event_on_widget_test.dart +++ b/packages/flutter/test/gestures/gesture_binding_resample_event_on_widget_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.8 - // Logically this file should be part of `gesture_binding_test.dart` but is here // due to conflict of `flutter_test` and `package:test`. // See https://github.com/dart-lang/matcher/issues/98 @@ -75,10 +73,10 @@ void main() { ), ); - GestureBinding.instance.resamplingEnabled = true; + GestureBinding.instance!.resamplingEnabled = true; const Duration kSamplingOffset = Duration(microseconds: -5500); - GestureBinding.instance.samplingOffset = kSamplingOffset; - ui.window.onPointerDataPacket(packet); + GestureBinding.instance!.samplingOffset = kSamplingOffset; + ui.window.onPointerDataPacket!(packet); expect(events.length, 0); await tester.pump(const Duration(milliseconds: 7)); diff --git a/packages/flutter/test/gestures/resampler_test.dart b/packages/flutter/test/gestures/resampler_test.dart index 0d5e968f759..28999bc536f 100644 --- a/packages/flutter/test/gestures/resampler_test.dart +++ b/packages/flutter/test/gestures/resampler_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.8 - import 'dart:ui'; import 'package:flutter/gestures.dart'; diff --git a/packages/flutter/test/image_data.dart b/packages/flutter/test/image_data.dart index 4af22490cf6..22ee7b23281 100644 --- a/packages/flutter/test/image_data.dart +++ b/packages/flutter/test/image_data.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.8 - /// A 50x50 blue square png. const List kBlueSquarePng = [ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, diff --git a/packages/flutter/test/painting/alignment_test.dart b/packages/flutter/test/painting/alignment_test.dart index 84dc172c006..5dbf5db8cae 100644 --- a/packages/flutter/test/painting/alignment_test.dart +++ b/packages/flutter/test/painting/alignment_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.8 - import 'dart:math' as math; import 'package:flutter/painting.dart'; @@ -110,14 +108,14 @@ void main() { final AlignmentGeometry mixed3 = const Alignment(25.0, 42.5).add(const AlignmentDirectional(55.0, 80.0)); for (final TextDirection direction in TextDirection.values) { - expect(AlignmentGeometry.lerp(mixed1, mixed2, 0.0).resolve(direction), mixed1.resolve(direction)); - expect(AlignmentGeometry.lerp(mixed1, mixed2, 1.0).resolve(direction), mixed2.resolve(direction)); - expect(AlignmentGeometry.lerp(mixed1, mixed2, 0.25).resolve(direction), mixed3.resolve(direction)); + expect(AlignmentGeometry.lerp(mixed1, mixed2, 0.0)!.resolve(direction), mixed1.resolve(direction)); + expect(AlignmentGeometry.lerp(mixed1, mixed2, 1.0)!.resolve(direction), mixed2.resolve(direction)); + expect(AlignmentGeometry.lerp(mixed1, mixed2, 0.25)!.resolve(direction), mixed3.resolve(direction)); } }); test('lerp commutes with resolve', () { - final List offsets = [ + final List offsets = [ Alignment.topLeft, Alignment.topCenter, Alignment.topRight, @@ -154,19 +152,19 @@ void main() { for (final TextDirection direction in TextDirection.values) { final Alignment defaultValue = AlignmentDirectional.center.resolve(direction); - for (final AlignmentGeometry a in offsets) { + for (final AlignmentGeometry? a in offsets) { final Alignment resolvedA = a?.resolve(direction) ?? defaultValue; - for (final AlignmentGeometry b in offsets) { + for (final AlignmentGeometry? b in offsets) { final Alignment resolvedB = b?.resolve(direction) ?? defaultValue; - approxExpect(Alignment.lerp(resolvedA, resolvedB, 0.0), resolvedA); - approxExpect(Alignment.lerp(resolvedA, resolvedB, 1.0), resolvedB); + approxExpect(Alignment.lerp(resolvedA, resolvedB, 0.0)!, resolvedA); + approxExpect(Alignment.lerp(resolvedA, resolvedB, 1.0)!, resolvedB); approxExpect((AlignmentGeometry.lerp(a, b, 0.0) ?? defaultValue).resolve(direction), resolvedA); approxExpect((AlignmentGeometry.lerp(a, b, 1.0) ?? defaultValue).resolve(direction), resolvedB); for (final double t in times) { assert(t > 0.0); assert(t < 1.0); final Alignment value = (AlignmentGeometry.lerp(a, b, t) ?? defaultValue).resolve(direction); - approxExpect(value, Alignment.lerp(resolvedA, resolvedB, t)); + approxExpect(value, Alignment.lerp(resolvedA, resolvedB, t)!); final double minDX = math.min(resolvedA.x, resolvedB.x); final double maxDX = math.max(resolvedA.x, resolvedB.x); final double minDY = math.min(resolvedA.y, resolvedB.y); diff --git a/packages/flutter/test/painting/beveled_rectangle_border_test.dart b/packages/flutter/test/painting/beveled_rectangle_border_test.dart index c77d4653779..2413c35d6ac 100644 --- a/packages/flutter/test/painting/beveled_rectangle_border_test.dart +++ b/packages/flutter/test/painting/beveled_rectangle_border_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.8 - import 'package:flutter/painting.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/painting/binding_test.dart b/packages/flutter/test/painting/binding_test.dart index bea214f2786..0ec864d320c 100644 --- a/packages/flutter/test/painting/binding_test.dart +++ b/packages/flutter/test/painting/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.8 - import 'dart:ui' as ui; import 'package:flutter/foundation.dart'; @@ -18,7 +16,7 @@ Future main() async { final ui.Image image = await createTestImage(); testWidgets('didHaveMemoryPressure clears imageCache', (WidgetTester tester) async { - imageCache.putIfAbsent(1, () => OneFrameImageStreamCompleter( + imageCache!.putIfAbsent(1, () => OneFrameImageStreamCompleter( Future.value(ImageInfo( image: image, scale: 1.0, @@ -26,11 +24,11 @@ Future main() async { ))); await tester.idle(); - expect(imageCache.currentSize, 1); + expect(imageCache!.currentSize, 1); final ByteData message = const JSONMessageCodec().encodeMessage( - {'type': 'memoryPressure'}); - await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage('flutter/system', message, (_) { }); - expect(imageCache.currentSize, 0); + {'type': 'memoryPressure'})!; + await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/system', message, (_) { }); + expect(imageCache!.currentSize, 0); }); test('evict clears live references', () async { @@ -71,19 +69,19 @@ class TestBindingBase implements BindingBase { } @override - void registerBoolServiceExtension({String name, AsyncValueGetter getter, AsyncValueSetter setter}) {} + void registerBoolServiceExtension({required String name, required AsyncValueGetter getter, required AsyncValueSetter setter}) {} @override - void registerNumericServiceExtension({String name, AsyncValueGetter getter, AsyncValueSetter setter}) {} + void registerNumericServiceExtension({required String name, required AsyncValueGetter getter, required AsyncValueSetter setter}) {} @override - void registerServiceExtension({String name, ServiceExtensionCallback callback}) {} + void registerServiceExtension({required String name, required ServiceExtensionCallback callback}) {} @override - void registerSignalServiceExtension({String name, AsyncCallback callback}) {} + void registerSignalServiceExtension({required String name, required AsyncCallback callback}) {} @override - void registerStringServiceExtension({String name, AsyncValueGetter getter, AsyncValueSetter setter}) {} + void registerStringServiceExtension({required String name, required AsyncValueGetter getter, required AsyncValueSetter setter}) {} @override void unlocked() {} diff --git a/packages/flutter/test/painting/border_radius_test.dart b/packages/flutter/test/painting/border_radius_test.dart index 375a103a146..665a265cb37 100644 --- a/packages/flutter/test/painting/border_radius_test.dart +++ b/packages/flutter/test/painting/border_radius_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.8 - import 'package:flutter/painting.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -365,10 +363,10 @@ void main() { bottomLeft: Radius.elliptical(95.0, 105.0), // 50,60 -> 140,150 bottomRight: Radius.elliptical(60.0, 65.0), // 0,0 -> 120,130 ); - expect(BorderRadiusGeometry.lerp(a, b, 0.5).resolve(TextDirection.ltr), ltr); - expect(BorderRadiusGeometry.lerp(a, b, 0.5).resolve(TextDirection.rtl), rtl); - expect(BorderRadiusGeometry.lerp(a, b, 0.0).resolve(TextDirection.ltr), a); - expect(BorderRadiusGeometry.lerp(a, b, 1.0).resolve(TextDirection.rtl), b.resolve(TextDirection.rtl)); + expect(BorderRadiusGeometry.lerp(a, b, 0.5)!.resolve(TextDirection.ltr), ltr); + expect(BorderRadiusGeometry.lerp(a, b, 0.5)!.resolve(TextDirection.rtl), rtl); + expect(BorderRadiusGeometry.lerp(a, b, 0.0)!.resolve(TextDirection.ltr), a); + expect(BorderRadiusGeometry.lerp(a, b, 1.0)!.resolve(TextDirection.rtl), b.resolve(TextDirection.rtl)); }); test('BorderRadiusGeometry subtract', () { diff --git a/packages/flutter/test/painting/border_rtl_test.dart b/packages/flutter/test/painting/border_rtl_test.dart index cfa5badda04..495d9497d5c 100644 --- a/packages/flutter/test/painting/border_rtl_test.dart +++ b/packages/flutter/test/painting/border_rtl_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.8 - import 'package:flutter/foundation.dart' show DiagnosticLevel, FlutterError; import 'package:flutter/painting.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -77,7 +75,7 @@ void main() { expect(BoxBorder.lerp(null, directionalWithTop10, 0.25), const BorderDirectional(top: BorderSide(width: 2.5))); expect(BoxBorder.lerp(directionalWithTop10, visualWithTop100, 0.25), const Border(top: BorderSide(width: 32.5))); expect(BoxBorder.lerp(visualWithSides10, directionalWithMagentaTop5, 0.25), visualWithSides10At75 + directionalWithMagentaTop5At25); - expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.25), Border(top: BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.25)))); + expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.25), Border(top: BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.25)!))); expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.25), visualWithSides10At50); expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.25), visualWithYellowTop5At75 + directionalWithSides10At25); expect(() => BoxBorder.lerp(SillyBorder(), const Border(), 0.25), throwsFlutterError); @@ -89,7 +87,7 @@ void main() { expect(BoxBorder.lerp(null, directionalWithTop10, 0.75), const BorderDirectional(top: BorderSide(width: 7.5))); expect(BoxBorder.lerp(directionalWithTop10, visualWithTop100, 0.75), const Border(top: BorderSide(width: 77.5))); expect(BoxBorder.lerp(visualWithSides10, directionalWithMagentaTop5, 0.75), visualWithSides10At25 + directionalWithMagentaTop5At75); - expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.75), Border(top: BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.75)))); + expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.75), Border(top: BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.75)!))); expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.75), directionalWithSides10At50); expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.75), visualWithYellowTop5At25 + directionalWithSides10At75); expect(() => BoxBorder.lerp(SillyBorder(), const Border(), 0.75), throwsFlutterError); @@ -120,7 +118,7 @@ void main() { }); test('BoxBorder.lerp throws correct FlutterError message', () { - FlutterError error; + late FlutterError error; try { BoxBorder.lerp(SillyBorder(), const Border(), 2.0); } on FlutterError catch (e) { @@ -353,13 +351,6 @@ void main() { ); }); - test('BorderDirectional constructor', () { - expect(() => BorderDirectional(top: nonconst(null)), throwsAssertionError); - expect(() => BorderDirectional(start: nonconst(null)), throwsAssertionError); - expect(() => BorderDirectional(end: nonconst(null)), throwsAssertionError); - expect(() => BorderDirectional(bottom: nonconst(null)), throwsAssertionError); - }); - test('BorderDirectional.merge', () { const BorderSide magenta3 = BorderSide(color: Color(0xFFFF00FF), width: 3.0); const BorderSide magenta6 = BorderSide(color: Color(0xFFFF00FF), width: 6.0); diff --git a/packages/flutter/test/painting/border_side_test.dart b/packages/flutter/test/painting/border_side_test.dart index edb59ab63c2..93d12f602dc 100644 --- a/packages/flutter/test/painting/border_side_test.dart +++ b/packages/flutter/test/painting/border_side_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.8 - import 'package:flutter/painting.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -17,9 +15,6 @@ void main() { style: BorderStyle.solid, ), ); - expect(() => BorderSide(color: nonconst(null)), throwsAssertionError); - expect(() => BorderSide(width: nonconst(null)), throwsAssertionError); - expect(() => BorderSide(style: nonconst(null)), throwsAssertionError); expect(() => BorderSide(width: nonconst(-1.0)), throwsAssertionError); expect( const BorderSide(width: -0.0), @@ -56,11 +51,8 @@ void main() { expect( BorderSide.canMerge(none3, BorderSide.none), isTrue); expect( BorderSide.canMerge(none3, side2), isFalse); expect( BorderSide.canMerge(none3, yellowNone), isTrue); - expect(() => BorderSide.canMerge(null, null), throwsAssertionError); - expect(() => BorderSide.canMerge(null, side2), throwsAssertionError); expect( BorderSide.canMerge(side2, BorderSide.none), isTrue); expect( BorderSide.canMerge(side2, none3), isFalse); - expect(() => BorderSide.canMerge(side2, null), throwsAssertionError); expect( BorderSide.canMerge(side2, side3), isTrue); expect( BorderSide.canMerge(side2, yellowNone), isTrue); expect( BorderSide.canMerge(side3, side2), isTrue); @@ -78,11 +70,8 @@ void main() { expect( BorderSide.merge(none3, BorderSide.none), none3); expect(() => BorderSide.merge(none3, side2), throwsAssertionError); expect( BorderSide.merge(none3, yellowNone), none3); - expect(() => BorderSide.merge(null, null), throwsAssertionError); - expect(() => BorderSide.merge(null, side2), throwsAssertionError); expect( BorderSide.merge(side2, BorderSide.none), side2); expect(() => BorderSide.merge(side2, none3), throwsAssertionError); - expect(() => BorderSide.merge(side2, null), throwsAssertionError); expect( BorderSide.merge(side2, side3), side5); expect( BorderSide.merge(side2, yellowNone), side2); expect( BorderSide.merge(side3, side2), side5); diff --git a/packages/flutter/test/painting/border_test.dart b/packages/flutter/test/painting/border_test.dart index 0c7e8db77cf..5c261c30353 100644 --- a/packages/flutter/test/painting/border_test.dart +++ b/packages/flutter/test/painting/border_test.dart @@ -2,21 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// @dart = 2.8 - import 'package:flutter/painting.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - test('Border constructor', () { - expect(() => Border(left: nonconst(null)), throwsAssertionError); - expect(() => Border(top: nonconst(null)), throwsAssertionError); - expect(() => Border(right: nonconst(null)), throwsAssertionError); - expect(() => Border(bottom: nonconst(null)), throwsAssertionError); - }); - test('Border.uniform constructor', () { - expect(() => Border.fromBorderSide(null), throwsAssertionError); const BorderSide side = BorderSide(); const Border border = Border.fromBorderSide(side); expect(border.left, same(side)); @@ -26,8 +16,6 @@ void main() { }); test('Border.symmetric constructor', () { - expect(() => Border.symmetric(vertical: nonconst(null)), throwsAssertionError); - expect(() => Border.symmetric(horizontal: nonconst(null)), throwsAssertionError); const BorderSide side1 = BorderSide(color: Color(0xFFFFFFFF)); const BorderSide side2 = BorderSide(color: Color(0xFF000000)); const Border border = Border.symmetric(vertical: side1, horizontal: side2); diff --git a/packages/flutter/test/painting/box_decoration_test.dart b/packages/flutter/test/painting/box_decoration_test.dart index 44a8eeb4325..47891501ec5 100644 --- a/packages/flutter/test/painting/box_decoration_test.dart +++ b/packages/flutter/test/painting/box_decoration_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.8 - import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/painting.dart'; diff --git a/packages/flutter/test/painting/box_fit_test.dart b/packages/flutter/test/painting/box_fit_test.dart index 91437c75707..fdc8145eafb 100644 --- a/packages/flutter/test/painting/box_fit_test.dart +++ b/packages/flutter/test/painting/box_fit_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.8 - import 'package:flutter/painting.dart'; import '../flutter_test_alternative.dart'; diff --git a/packages/flutter/test/painting/box_painter_test.dart b/packages/flutter/test/painting/box_painter_test.dart index e9c5141534d..a57c6e5b916 100644 --- a/packages/flutter/test/painting/box_painter_test.dart +++ b/packages/flutter/test/painting/box_painter_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.8 - import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/painting.dart'; @@ -26,7 +24,7 @@ void main() { expect(BorderSide.lerp(side1, side2, 0.0), equals(side1)); expect(BorderSide.lerp(side1, side2, 1.0), equals(side2)); expect(BorderSide.lerp(side1, side2, 0.5), equals(BorderSide( - color: Color.lerp(const Color(0xFF000000), const Color(0xFF00FFFF), 0.5), + color: Color.lerp(const Color(0xFF000000), const Color(0xFF00FFFF), 0.5)!, width: 1.5, style: BorderStyle.solid, ))); @@ -55,8 +53,8 @@ void main() { test('Border control test', () { final Border border1 = Border.all(width: 4.0); - final Border border2 = Border.lerp(null, border1, 0.25); - final Border border3 = Border.lerp(border1, null, 0.25); + final Border border2 = Border.lerp(null, border1, 0.25)!; + final Border border3 = Border.lerp(border1, null, 0.25)!; expect(border1, hasOneLineDescription); expect(border1.hashCode, isNot(equals(border2.hashCode))); @@ -64,7 +62,7 @@ void main() { expect(border2.top.width, equals(1.0)); expect(border3.bottom.width, equals(3.0)); - final Border border4 = Border.lerp(border2, border3, 0.5); + final Border border4 = Border.lerp(border2, border3, 0.5)!; expect(border4.left.width, equals(2.0)); }); @@ -90,8 +88,8 @@ void main() { test('BoxShadow control test', () { const BoxShadow shadow1 = BoxShadow(blurRadius: 4.0); - final BoxShadow shadow2 = BoxShadow.lerp(null, shadow1, 0.25); - final BoxShadow shadow3 = BoxShadow.lerp(shadow1, null, 0.25); + final BoxShadow shadow2 = BoxShadow.lerp(null, shadow1, 0.25)!; + final BoxShadow shadow3 = BoxShadow.lerp(shadow1, null, 0.25)!; expect(shadow1, hasOneLineDescription); expect(shadow1.hashCode, isNot(equals(shadow2.hashCode))); @@ -100,14 +98,14 @@ void main() { expect(shadow2.blurRadius, equals(1.0)); expect(shadow3.blurRadius, equals(3.0)); - final BoxShadow shadow4 = BoxShadow.lerp(shadow2, shadow3, 0.5); + final BoxShadow shadow4 = BoxShadow.lerp(shadow2, shadow3, 0.5)!; expect(shadow4.blurRadius, equals(2.0)); List shadowList = BoxShadow.lerpList( - [shadow2, shadow1], [shadow3], 0.5); + [shadow2, shadow1], [shadow3], 0.5)!; expect(shadowList, equals([shadow4, shadow1.scale(0.5)])); shadowList = BoxShadow.lerpList( - [shadow2], [shadow3, shadow1], 0.5); + [shadow2], [shadow3, shadow1], 0.5)!; expect(shadowList, equals([shadow4, shadow1.scale(0.5)])); }); diff --git a/packages/flutter/test/painting/circle_border_test.dart b/packages/flutter/test/painting/circle_border_test.dart index 99fb87a0e33..3cf3bad1b05 100644 --- a/packages/flutter/test/painting/circle_border_test.dart +++ b/packages/flutter/test/painting/circle_border_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.8 - import 'package:flutter/painting.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/painting/colors_test.dart b/packages/flutter/test/painting/colors_test.dart index 427058e2600..1c4e92aefb6 100644 --- a/packages/flutter/test/painting/colors_test.dart +++ b/packages/flutter/test/painting/colors_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.8 - import 'package:flutter/foundation.dart'; import 'package:flutter/painting.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -25,7 +23,7 @@ void main() { expect(color.toColor(), const Color(0xb399816b)); - final HSVColor result = HSVColor.lerp(color, const HSVColor.fromAHSV(0.3, 128.0, 0.7, 0.2), 0.25); + final HSVColor result = HSVColor.lerp(color, const HSVColor.fromAHSV(0.3, 128.0, 0.7, 0.2), 0.25)!; expect(result.alpha, moreOrLessEquals(0.6)); expect(result.hue, moreOrLessEquals(53.0)); expect(result.saturation, greaterThan(0.3999)); @@ -129,7 +127,7 @@ void main() { const HSVColor endColor = HSVColor.fromAHSV(1.0, 360.0, 1.0, 1.0); for (double t = -0.5; t < 1.5; t += 0.1) { - output.add(HSVColor.lerp(startColor, endColor, t).toColor()); + output.add(HSVColor.lerp(startColor, endColor, t)!.toColor()); } final List expectedColors = [ const Color(0xff00ffff), @@ -162,7 +160,7 @@ void main() { const HSVColor endColor = HSVColor.fromAHSV(1.0, 0.0, 1.0, 1.0); for (double t = -0.1; t < 1.1; t += 0.1) { - output.add(HSVColor.lerp(startColor, endColor, t).toColor()); + output.add(HSVColor.lerp(startColor, endColor, t)!.toColor()); } final List expectedColors = [ const Color(0xffffffff), @@ -188,7 +186,7 @@ void main() { const HSVColor endColor = HSVColor.fromAHSV(1.0, 0.0, 1.0, 1.0); for (double t = -0.1; t < 1.1; t += 0.1) { - output.add(HSVColor.lerp(startColor, endColor, t).toColor()); + output.add(HSVColor.lerp(startColor, endColor, t)!.toColor()); } final List expectedColors = [ const Color(0xff000000), @@ -221,7 +219,7 @@ void main() { expect(color.toColor(), const Color(0xb3b8977a)); - final HSLColor result = HSLColor.lerp(color, const HSLColor.fromAHSL(0.3, 128.0, 0.7, 0.2), 0.25); + final HSLColor result = HSLColor.lerp(color, const HSLColor.fromAHSL(0.3, 128.0, 0.7, 0.2), 0.25)!; expect(result.alpha, moreOrLessEquals(0.6)); expect(result.hue, moreOrLessEquals(53.0)); expect(result.saturation, greaterThan(0.3999)); @@ -324,7 +322,7 @@ void main() { const HSLColor endColor = HSLColor.fromAHSL(1.0, 360.0, 0.5, 0.5); for (double t = -0.5; t < 1.5; t += 0.1) { - output.add(HSLColor.lerp(startColor, endColor, t).toColor()); + output.add(HSLColor.lerp(startColor, endColor, t)!.toColor()); } final List expectedColors = [ const Color(0xff40bfbf), @@ -357,7 +355,7 @@ void main() { const HSLColor endColor = HSLColor.fromAHSL(1.0, 0.0, 1.0, 0.5); for (double t = -0.1; t < 1.1; t += 0.1) { - output.add(HSLColor.lerp(startColor, endColor, t).toColor()); + output.add(HSLColor.lerp(startColor, endColor, t)!.toColor()); } final List expectedColors = [ const Color(0xff808080), @@ -383,7 +381,7 @@ void main() { const HSLColor endColor = HSLColor.fromAHSL(1.0, 0.0, 0.5, 1.0); for (double t = -0.1; t < 1.1; t += 0.1) { - output.add(HSLColor.lerp(startColor, endColor, t).toColor()); + output.add(HSLColor.lerp(startColor, endColor, t)!.toColor()); } final List expectedColors = [ const Color(0xff000000), @@ -438,7 +436,7 @@ void main() { expect(valueProperties['blue'], 40); property = ColorProperty('foo', null); - final Map json = property.toJsonMap(const DiagnosticsSerializationDelegate()); + final Map json = property.toJsonMap(const DiagnosticsSerializationDelegate()); expect(json.containsKey('valueProperties'), isFalse); }); diff --git a/packages/flutter/test/painting/common_matchers.dart b/packages/flutter/test/painting/common_matchers.dart index 81d67626c60..3a5bf43fa53 100644 --- a/packages/flutter/test/painting/common_matchers.dart +++ b/packages/flutter/test/painting/common_matchers.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.8 - import 'package:flutter/painting.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/painting/continuous_rectangle_border_test.dart b/packages/flutter/test/painting/continuous_rectangle_border_test.dart index 9631959ea20..78d0bc4d138 100644 --- a/packages/flutter/test/painting/continuous_rectangle_border_test.dart +++ b/packages/flutter/test/painting/continuous_rectangle_border_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.8 - import 'package:flutter/material.dart'; import 'package:flutter/painting.dart'; import 'package:flutter_test/flutter_test.dart'; diff --git a/packages/flutter/test/painting/decoration_test.dart b/packages/flutter/test/painting/decoration_test.dart index a4161f0ba17..e85fa68ac6d 100644 --- a/packages/flutter/test/painting/decoration_test.dart +++ b/packages/flutter/test/painting/decoration_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.8 - @TestOn('!chrome') import 'dart:async'; import 'dart:ui' as ui show Image, ColorFilter; @@ -17,13 +15,11 @@ import '../painting/mocks_for_image_cache.dart'; import '../rendering/rendering_tester.dart'; class TestCanvas implements Canvas { - TestCanvas([this.invocations]); - - final List invocations; + final List invocations = []; @override void noSuchMethod(Invocation invocation) { - invocations?.add(invocation); + invocations.add(invocation); } } @@ -177,7 +173,7 @@ void main() { // A reference test would be better. test('BoxDecoration backgroundImage clip', () async { final ui.Image image = await createTestImage(width: 100, height: 100); - void testDecoration({ BoxShape shape = BoxShape.rectangle, BorderRadius borderRadius, bool expectClip }) { + void testDecoration({ BoxShape shape = BoxShape.rectangle, BorderRadius? borderRadius, required bool expectClip }) { assert(shape != null); FakeAsync().run((FakeAsync async) async { final DelayedImageProvider imageProvider = DelayedImageProvider(image); @@ -189,8 +185,7 @@ void main() { image: backgroundImage, ); - final List invocations = []; - final TestCanvas canvas = TestCanvas(invocations); + final TestCanvas canvas = TestCanvas(); const ImageConfiguration imageConfiguration = ImageConfiguration( size: Size(100.0, 100.0) ); @@ -244,7 +239,7 @@ void main() { final BoxDecoration boxDecoration = BoxDecoration(image: backgroundImage); final BoxPainter boxPainter = boxDecoration.createBoxPainter(() { assert(false); }); - final TestCanvas canvas = TestCanvas([]); + final TestCanvas canvas = TestCanvas(); boxPainter.paint(canvas, Offset.zero, const ImageConfiguration(size: Size(100.0, 100.0))); final Invocation call = canvas.invocations.singleWhere((Invocation call) => call.memberName == #drawImageNine); @@ -270,8 +265,8 @@ void main() { final BoxPainter boxPainter = boxDecoration.createBoxPainter(() { assert(false); }); - final TestCanvas canvas = TestCanvas([]); - FlutterError error; + final TestCanvas canvas = TestCanvas(); + late FlutterError error; try { boxPainter.paint(canvas, Offset.zero, const ImageConfiguration( size: Size(100.0, 100.0), textDirection: null)); @@ -297,10 +292,10 @@ void main() { }); test('DecorationImage - error listener', () async { - String exception; + late String exception; final DecorationImage backgroundImage = DecorationImage( image: const SynchronousErrorTestImageProvider('threw'), - onError: (dynamic error, StackTrace stackTrace) { + onError: (dynamic error, StackTrace? stackTrace) { exception = error as String; } ); @@ -430,7 +425,7 @@ void main() { test('paintImage BoxFit.none scale test', () async { for (double scale = 1.0; scale <= 4.0; scale += 1.0) { - final TestCanvas canvas = TestCanvas([]); + final TestCanvas canvas = TestCanvas(); const Rect outputRect = Rect.fromLTWH(30.0, 30.0, 250.0, 250.0); final ui.Image image = await createTestImage(width: 100, height: 100); @@ -473,7 +468,7 @@ void main() { test('paintImage BoxFit.scaleDown scale test', () async { for (double scale = 1.0; scale <= 4.0; scale += 1.0) { - final TestCanvas canvas = TestCanvas([]); + final TestCanvas canvas = TestCanvas(); // container size > scaled image size const Rect outputRect = Rect.fromLTWH(30.0, 30.0, 250.0, 250.0); @@ -516,7 +511,7 @@ void main() { }); test('paintImage BoxFit.scaleDown test', () async { - final TestCanvas canvas = TestCanvas([]); + final TestCanvas canvas = TestCanvas(); // container height (20 px) < scaled image height (50 px) const Rect outputRect = Rect.fromLTWH(30.0, 30.0, 250.0, 20.0); @@ -569,7 +564,7 @@ void main() { ]; for (final BoxFit boxFit in boxFits) { - final TestCanvas canvas = TestCanvas([]); + final TestCanvas canvas = TestCanvas(); const Rect outputRect = Rect.fromLTWH(30.0, 30.0, 250.0, 250.0); final ui.Image image = await createTestImage(width: 100, height: 100); @@ -595,18 +590,6 @@ void main() { } }); - test('scale cannot be null in DecorationImage', () async { - final ui.Image image = await createTestImage(width: 100, height: 100); - try { - DecorationImage(scale: null, image: SynchronousTestImageProvider(image)); - } on AssertionError catch (error) { - expect(error.toString(), contains('scale != null')); - expect(error.toString(), contains('is not true')); - return; - } - fail('DecorationImage did not throw AssertionError when scale was null'); - }); - test('DecorationImage scale test', () async { final ui.Image image = await createTestImage(width: 100, height: 100); final DecorationImage backgroundImage = DecorationImage( @@ -617,7 +600,7 @@ void main() { final BoxDecoration boxDecoration = BoxDecoration(image: backgroundImage); final BoxPainter boxPainter = boxDecoration.createBoxPainter(() { assert(false); }); - final TestCanvas canvas = TestCanvas([]); + final TestCanvas canvas = TestCanvas(); boxPainter.paint(canvas, Offset.zero, const ImageConfiguration(size: Size(100.0, 100.0))); final Invocation call = canvas.invocations.firstWhere((Invocation call) => call.memberName == #drawImageRect); diff --git a/packages/flutter/test/painting/edge_insets_test.dart b/packages/flutter/test/painting/edge_insets_test.dart index e7b13cf7b28..74d4ba4c291 100644 --- a/packages/flutter/test/painting/edge_insets_test.dart +++ b/packages/flutter/test/painting/edge_insets_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.8 - import 'package:flutter/painting.dart'; import 'package:flutter_test/flutter_test.dart';