Unverified Commit bb73121c authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Remove unnecessary null checks in flutter/test (#118905)

parent 288a7733
...@@ -1830,7 +1830,6 @@ void main() { ...@@ -1830,7 +1830,6 @@ void main() {
child: const Text('Home'), child: const Text('Home'),
onPressed: () { onPressed: () {
navigator = Navigator.of(context); navigator = Navigator.of(context);
assert(navigator != null);
navigator.push<void>(r); navigator.push<void>(r);
}, },
); );
......
...@@ -29,7 +29,6 @@ class TestGestureFlutterBinding extends BindingBase with GestureBinding { ...@@ -29,7 +29,6 @@ class TestGestureFlutterBinding extends BindingBase with GestureBinding {
); );
Future<void> test(VoidCallback callback) { Future<void> test(VoidCallback callback) {
assert(callback != null);
return _binding.lockEvents(() async { return _binding.lockEvents(() async {
GestureBinding.instance.platformDispatcher.onPointerDataPacket?.call(packet); GestureBinding.instance.platformDispatcher.onPointerDataPacket?.call(packet);
callback(); callback();
...@@ -41,7 +40,6 @@ late TestGestureFlutterBinding _binding; ...@@ -41,7 +40,6 @@ late TestGestureFlutterBinding _binding;
void main() { void main() {
_binding = TestGestureFlutterBinding(); _binding = TestGestureFlutterBinding();
assert(GestureBinding.instance != null);
test('Pointer events are locked during reassemble', () async { test('Pointer events are locked during reassemble', () async {
final List<PointerEvent> events = <PointerEvent>[]; final List<PointerEvent> events = <PointerEvent>[];
......
...@@ -13,8 +13,7 @@ bool _withinTolerance(double actual, double expected) { ...@@ -13,8 +13,7 @@ bool _withinTolerance(double actual, double expected) {
} }
bool _checkVelocity(Velocity actual, Offset expected) { bool _checkVelocity(Velocity actual, Offset expected) {
return (actual != null) return _withinTolerance(actual.pixelsPerSecond.dx, expected.dx)
&& _withinTolerance(actual.pixelsPerSecond.dx, expected.dx)
&& _withinTolerance(actual.pixelsPerSecond.dy, expected.dy); && _withinTolerance(actual.pixelsPerSecond.dy, expected.dy);
} }
......
...@@ -2491,7 +2491,6 @@ void main() { ...@@ -2491,7 +2491,6 @@ void main() {
} }
Widget boilerplate({ Widget? bottomNavigationBar, required TextDirection textDirection }) { Widget boilerplate({ Widget? bottomNavigationBar, required TextDirection textDirection }) {
assert(textDirection != null);
return MaterialApp( return MaterialApp(
home: Localizations( home: Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
......
...@@ -1506,7 +1506,7 @@ void main() { ...@@ -1506,7 +1506,7 @@ void main() {
StatefulBuilder(builder: (BuildContext context, StateSetter setState) { StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
return RawChip( return RawChip(
avatar: avatar, avatar: avatar,
onSelected: selectable != null onSelected: selectable
? (bool value) { ? (bool value) {
setState(() { setState(() {
selected = value; selected = value;
...@@ -1585,7 +1585,7 @@ void main() { ...@@ -1585,7 +1585,7 @@ void main() {
children: <Widget>[ children: <Widget>[
StatefulBuilder(builder: (BuildContext context, StateSetter setState) { StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
return RawChip( return RawChip(
onSelected: selectable != null onSelected: selectable
? (bool value) { ? (bool value) {
setState(() { setState(() {
selected = value; selected = value;
...@@ -1659,7 +1659,7 @@ void main() { ...@@ -1659,7 +1659,7 @@ void main() {
StatefulBuilder(builder: (BuildContext context, StateSetter setState) { StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
return RawChip( return RawChip(
avatar: avatar, avatar: avatar,
onSelected: selectable != null onSelected: selectable
? (bool value) { ? (bool value) {
setState(() { setState(() {
selected = value; selected = value;
......
...@@ -717,7 +717,6 @@ void main() { ...@@ -717,7 +717,6 @@ void main() {
expect(itemBoxes.length, equals(2)); expect(itemBoxes.length, equals(2));
for (final RenderBox itemBox in itemBoxes) { for (final RenderBox itemBox in itemBoxes) {
assert(itemBox.attached); assert(itemBox.attached);
assert(textDirection != null);
switch (textDirection) { switch (textDirection) {
case TextDirection.rtl: case TextDirection.rtl:
expect( expect(
...@@ -1145,13 +1144,11 @@ void main() { ...@@ -1145,13 +1144,11 @@ void main() {
tester.element(find.byType(ListView)).visitAncestorElements((Element element) { tester.element(find.byType(ListView)).visitAncestorElements((Element element) {
if (element.toString().startsWith('_DropdownMenu')) { if (element.toString().startsWith('_DropdownMenu')) {
final RenderBox box = element.findRenderObject()! as RenderBox; final RenderBox box = element.findRenderObject()! as RenderBox;
assert(box != null);
menuRect = box.localToGlobal(Offset.zero) & box.size; menuRect = box.localToGlobal(Offset.zero) & box.size;
return false; return false;
} }
return true; return true;
}); });
assert(menuRect != null);
return menuRect; return menuRect;
} }
...@@ -1859,9 +1856,7 @@ void main() { ...@@ -1859,9 +1856,7 @@ void main() {
double getMenuScroll() { double getMenuScroll() {
double scrollPosition; double scrollPosition;
final ScrollController scrollController = PrimaryScrollController.of(tester.element(find.byType(ListView))); final ScrollController scrollController = PrimaryScrollController.of(tester.element(find.byType(ListView)));
assert(scrollController != null);
scrollPosition = scrollController.position.pixels; scrollPosition = scrollController.position.pixels;
assert(scrollPosition != null);
return scrollPosition; return scrollPosition;
} }
...@@ -1895,9 +1890,7 @@ void main() { ...@@ -1895,9 +1890,7 @@ void main() {
double getMenuScroll() { double getMenuScroll() {
double scrollPosition; double scrollPosition;
final ScrollController scrollController = PrimaryScrollController.of(tester.element(find.byType(ListView))); final ScrollController scrollController = PrimaryScrollController.of(tester.element(find.byType(ListView)));
assert(scrollController != null);
scrollPosition = scrollController.position.pixels; scrollPosition = scrollController.position.pixels;
assert(scrollPosition != null);
return scrollPosition; return scrollPosition;
} }
...@@ -1932,9 +1925,7 @@ void main() { ...@@ -1932,9 +1925,7 @@ void main() {
double getMenuScroll() { double getMenuScroll() {
double scrollPosition; double scrollPosition;
final ScrollController scrollController = PrimaryScrollController.of(tester.element(find.byType(ListView))); final ScrollController scrollController = PrimaryScrollController.of(tester.element(find.byType(ListView)));
assert(scrollController != null);
scrollPosition = scrollController.position.pixels; scrollPosition = scrollController.position.pixels;
assert(scrollPosition != null);
return scrollPosition; return scrollPosition;
} }
...@@ -1969,9 +1960,7 @@ void main() { ...@@ -1969,9 +1960,7 @@ void main() {
double getMenuScroll() { double getMenuScroll() {
double scrollPosition; double scrollPosition;
final ScrollController scrollController = PrimaryScrollController.of(tester.element(find.byType(ListView))); final ScrollController scrollController = PrimaryScrollController.of(tester.element(find.byType(ListView)));
assert(scrollController != null);
scrollPosition = scrollController.position.pixels; scrollPosition = scrollController.position.pixels;
assert(scrollPosition != null);
return scrollPosition; return scrollPosition;
} }
......
...@@ -132,8 +132,7 @@ void main() { ...@@ -132,8 +132,7 @@ void main() {
); );
final Iterable<double> currentRotations = rotationTransitions.map((RotationTransition t) => t.turns.value); final Iterable<double> currentRotations = rotationTransitions.map((RotationTransition t) => t.turns.value);
if (previousRotations != null && previousRotations!.isNotEmpty if (previousRotations != null && previousRotations!.isNotEmpty && currentRotations.isNotEmpty
&& currentRotations != null && currentRotations.isNotEmpty
&& previousRect != null && currentRect != null) { && previousRect != null && currentRect != null) {
final List<double> deltas = <double>[]; final List<double> deltas = <double>[];
for (final double currentRotation in currentRotations) { for (final double currentRotation in currentRotations) {
...@@ -1739,7 +1738,6 @@ class _StartTopFloatingActionButtonLocation extends FloatingActionButtonLocation ...@@ -1739,7 +1738,6 @@ class _StartTopFloatingActionButtonLocation extends FloatingActionButtonLocation
@override @override
Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) { Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) {
double fabX; double fabX;
assert(scaffoldGeometry.textDirection != null);
switch (scaffoldGeometry.textDirection) { switch (scaffoldGeometry.textDirection) {
case TextDirection.rtl: case TextDirection.rtl:
final double startPadding = kFloatingActionButtonMargin + scaffoldGeometry.minInsets.right; final double startPadding = kFloatingActionButtonMargin + scaffoldGeometry.minInsets.right;
......
...@@ -2774,7 +2774,7 @@ class _CustomPageRoute<T> extends PageRoute<T> { ...@@ -2774,7 +2774,7 @@ class _CustomPageRoute<T> extends PageRoute<T> {
RouteSettings super.settings = const RouteSettings(), RouteSettings super.settings = const RouteSettings(),
this.maintainState = true, this.maintainState = true,
super.fullscreenDialog, super.fullscreenDialog,
}) : assert(builder != null); });
final WidgetBuilder builder; final WidgetBuilder builder;
......
...@@ -1340,9 +1340,7 @@ void main() { ...@@ -1340,9 +1340,7 @@ void main() {
const Duration waitDuration = Duration(seconds: 1); const Duration waitDuration = Duration(seconds: 1);
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(() async { addTearDown(() async {
if (gesture != null) { return gesture.removePointer();
return gesture.removePointer();
}
}); });
await gesture.addPointer(); await gesture.addPointer();
await gesture.moveTo(const Offset(1.0, 1.0)); await gesture.moveTo(const Offset(1.0, 1.0));
......
...@@ -14,9 +14,7 @@ void main() { ...@@ -14,9 +14,7 @@ void main() {
testWidgets('Tooltip does not build MouseRegion when mouse is detected and in TooltipVisibility with visibility = false', (WidgetTester tester) async { testWidgets('Tooltip does not build MouseRegion when mouse is detected and in TooltipVisibility with visibility = false', (WidgetTester tester) async {
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(() async { addTearDown(() async {
if (gesture != null) { return gesture.removePointer();
return gesture.removePointer();
}
}); });
await gesture.addPointer(); await gesture.addPointer();
await gesture.moveTo(const Offset(1.0, 1.0)); await gesture.moveTo(const Offset(1.0, 1.0));
...@@ -45,9 +43,7 @@ void main() { ...@@ -45,9 +43,7 @@ void main() {
const Duration waitDuration = Duration.zero; const Duration waitDuration = Duration.zero;
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(() async { addTearDown(() async {
if (gesture != null) { return gesture.removePointer();
return gesture.removePointer();
}
}); });
await gesture.addPointer(); await gesture.addPointer();
await gesture.moveTo(const Offset(1.0, 1.0)); await gesture.moveTo(const Offset(1.0, 1.0));
......
...@@ -240,7 +240,6 @@ void main() { ...@@ -240,7 +240,6 @@ void main() {
test('BoxDecoration backgroundImage clip', () async { test('BoxDecoration backgroundImage clip', () async {
final ui.Image image = await createTestImage(width: 100, height: 100); final ui.Image image = await createTestImage(width: 100, height: 100);
void testDecoration({ BoxShape shape = BoxShape.rectangle, BorderRadius? borderRadius, required bool expectClip }) { void testDecoration({ BoxShape shape = BoxShape.rectangle, BorderRadius? borderRadius, required bool expectClip }) {
assert(shape != null);
FakeAsync().run((FakeAsync async) async { FakeAsync().run((FakeAsync async) async {
final DelayedImageProvider imageProvider = DelayedImageProvider(image); final DelayedImageProvider imageProvider = DelayedImageProvider(image);
final DecorationImage backgroundImage = DecorationImage(image: imageProvider); final DecorationImage backgroundImage = DecorationImage(image: imageProvider);
......
...@@ -42,8 +42,7 @@ class TestImageInfo extends ImageInfo { ...@@ -42,8 +42,7 @@ class TestImageInfo extends ImageInfo {
} }
class TestImageProvider extends ImageProvider<int> { class TestImageProvider extends ImageProvider<int> {
const TestImageProvider(this.key, this.imageValue, { required this.image }) const TestImageProvider(this.key, this.imageValue, { required this.image });
: assert(image != null);
final int key; final int key;
final int imageValue; final int imageValue;
......
...@@ -498,7 +498,7 @@ class _PathMatcher extends Matcher { ...@@ -498,7 +498,7 @@ class _PathMatcher extends Matcher {
} }
class _MismatchedCall { class _MismatchedCall {
const _MismatchedCall(this.message, this.callIntroduction, this.call) : assert(call != null); const _MismatchedCall(this.message, this.callIntroduction, this.call);
final String message; final String message;
final String callIntroduction; final String callIntroduction;
final RecordedInvocation call; final RecordedInvocation call;
......
...@@ -448,8 +448,7 @@ ui.PointerData _pointerData( ...@@ -448,8 +448,7 @@ ui.PointerData _pointerData(
} }
class _CursorUpdateDetails extends MethodCall { class _CursorUpdateDetails extends MethodCall {
const _CursorUpdateDetails(super.method, Map<String, dynamic> super.arguments) const _CursorUpdateDetails(super.method, Map<String, dynamic> super.arguments);
: assert(arguments != null);
_CursorUpdateDetails.wrap(MethodCall call) _CursorUpdateDetails.wrap(MethodCall call)
: super(call.method, Map<String, dynamic>.from(call.arguments as Map<dynamic, dynamic>)); : super(call.method, Map<String, dynamic>.from(call.arguments as Map<dynamic, dynamic>));
......
...@@ -43,19 +43,13 @@ void main() { ...@@ -43,19 +43,13 @@ void main() {
}) { }) {
final TestAnnotationTarget oneAnnotation = TestAnnotationTarget( final TestAnnotationTarget oneAnnotation = TestAnnotationTarget(
onEnter: (PointerEnterEvent event) { onEnter: (PointerEnterEvent event) {
if (logEvents != null) { logEvents.add(event);
logEvents.add(event);
}
}, },
onHover: (PointerHoverEvent event) { onHover: (PointerHoverEvent event) {
if (logEvents != null) { logEvents.add(event);
logEvents.add(event);
}
}, },
onExit: (PointerExitEvent event) { onExit: (PointerExitEvent event) {
if (logEvents != null) { logEvents.add(event);
logEvents.add(event);
}
}, },
); );
setUpMouseAnnotationFinder( setUpMouseAnnotationFinder(
...@@ -608,8 +602,7 @@ ui.PointerData _pointerData( ...@@ -608,8 +602,7 @@ ui.PointerData _pointerData(
} }
class BaseEventMatcher extends Matcher { class BaseEventMatcher extends Matcher {
BaseEventMatcher(this.expected) BaseEventMatcher(this.expected);
: assert(expected != null);
final PointerEvent expected; final PointerEvent expected;
......
...@@ -28,7 +28,6 @@ class RecordedInvocation { ...@@ -28,7 +28,6 @@ class RecordedInvocation {
/// Converts [stack] to a string using the [FlutterError.defaultStackFilter] logic. /// Converts [stack] to a string using the [FlutterError.defaultStackFilter] logic.
String stackToString({ String indent = '' }) { String stackToString({ String indent = '' }) {
assert(indent != null);
return indent + FlutterError.defaultStackFilter( return indent + FlutterError.defaultStackFilter(
stack.toString().trimRight().split('\n'), stack.toString().trimRight().split('\n'),
).join('\n$indent'); ).join('\n$indent');
...@@ -124,7 +123,6 @@ class TestRecordingPaintingContext extends ClipContext implements PaintingContex ...@@ -124,7 +123,6 @@ class TestRecordingPaintingContext extends ClipContext implements PaintingContex
Clip clipBehavior = Clip.antiAlias, Clip clipBehavior = Clip.antiAlias,
ClipRRectLayer? oldLayer, ClipRRectLayer? oldLayer,
}) { }) {
assert(clipBehavior != null);
clipRRectAndPaint(clipRRect.shift(offset), clipBehavior, bounds.shift(offset), () => painter(this, offset)); clipRRectAndPaint(clipRRect.shift(offset), clipBehavior, bounds.shift(offset), () => painter(this, offset));
return null; return null;
} }
......
...@@ -197,13 +197,12 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser ...@@ -197,13 +197,12 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser
/// ///
/// If `onErrors` is not null, it is set as [TestRenderingFlutterBinding.onError]. /// If `onErrors` is not null, it is set as [TestRenderingFlutterBinding.onError].
void layout( void layout(
RenderBox box, { RenderBox box, { // If you want to just repump the last box, call pumpFrame().
BoxConstraints? constraints, BoxConstraints? constraints,
Alignment alignment = Alignment.center, Alignment alignment = Alignment.center,
EnginePhase phase = EnginePhase.layout, EnginePhase phase = EnginePhase.layout,
VoidCallback? onErrors, VoidCallback? onErrors,
}) { }) {
assert(box != null); // If you want to just repump the last box, call pumpFrame().
assert(box.parent == null); // We stick the box in another, so you can't reuse it easily, sorry. assert(box.parent == null); // We stick the box in another, so you can't reuse it easily, sorry.
TestRenderingFlutterBinding.instance.renderView.child = null; TestRenderingFlutterBinding.instance.renderView.child = null;
...@@ -225,8 +224,6 @@ void layout( ...@@ -225,8 +224,6 @@ void layout(
/// ///
/// If `onErrors` is not null, it is set as [TestRenderingFlutterBinding.onError]. /// If `onErrors` is not null, it is set as [TestRenderingFlutterBinding.onError].
void pumpFrame({ EnginePhase phase = EnginePhase.layout, VoidCallback? onErrors }) { void pumpFrame({ EnginePhase phase = EnginePhase.layout, VoidCallback? onErrors }) {
assert(TestRenderingFlutterBinding.instance != null);
assert(TestRenderingFlutterBinding.instance.renderView != null);
assert(TestRenderingFlutterBinding.instance.renderView.child != null); // call layout() first! assert(TestRenderingFlutterBinding.instance.renderView.child != null); // call layout() first!
if (onErrors != null) { if (onErrors != null) {
......
...@@ -8,7 +8,7 @@ import 'package:flutter/services.dart'; ...@@ -8,7 +8,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
class FakeTextChannel implements MethodChannel { class FakeTextChannel implements MethodChannel {
FakeTextChannel(this.outgoing) : assert(outgoing != null); FakeTextChannel(this.outgoing);
Future<dynamic> Function(MethodCall) outgoing; Future<dynamic> Function(MethodCall) outgoing;
Future<void> Function(MethodCall)? incoming; Future<void> Function(MethodCall)? incoming;
......
...@@ -1869,8 +1869,7 @@ class ThirdTestIntent extends SecondTestIntent { ...@@ -1869,8 +1869,7 @@ class ThirdTestIntent extends SecondTestIntent {
class TestAction extends CallbackAction<TestIntent> { class TestAction extends CallbackAction<TestIntent> {
TestAction({ TestAction({
required OnInvokeCallback onInvoke, required OnInvokeCallback onInvoke,
}) : assert(onInvoke != null), }) : super(onInvoke: onInvoke);
super(onInvoke: onInvoke);
@override @override
bool isEnabled(TestIntent intent) => enabled; bool isEnabled(TestIntent intent) => enabled;
......
...@@ -507,7 +507,7 @@ void main() { ...@@ -507,7 +507,7 @@ void main() {
home: Scaffold( home: Scaffold(
body: RawAutocomplete<String>( body: RawAutocomplete<String>(
optionsBuilder: (TextEditingValue textEditingValue) { optionsBuilder: (TextEditingValue textEditingValue) {
if (textEditingValue.text == null || textEditingValue.text == '') { if (textEditingValue.text == '') {
return const Iterable<String>.empty(); return const Iterable<String>.empty();
} }
return kOptions.where((String option) { return kOptions.where((String option) {
......
...@@ -151,9 +151,7 @@ class RenderBaselineDetector extends RenderBox { ...@@ -151,9 +151,7 @@ class RenderBaselineDetector extends RenderBox {
@override @override
double computeDistanceToActualBaseline(TextBaseline baseline) { double computeDistanceToActualBaseline(TextBaseline baseline) {
if (callback != null) { callback();
callback();
}
return 20.0; return 20.0;
} }
......
...@@ -153,7 +153,7 @@ class LayoutWithMissingId extends ParentDataWidget<MultiChildLayoutParentData> { ...@@ -153,7 +153,7 @@ class LayoutWithMissingId extends ParentDataWidget<MultiChildLayoutParentData> {
const LayoutWithMissingId({ const LayoutWithMissingId({
super.key, super.key,
required super.child, required super.child,
}) : assert(child != null); });
@override @override
void applyParentData(RenderObject renderObject) {} void applyParentData(RenderObject renderObject) {}
......
...@@ -174,7 +174,6 @@ Future<void> dismissItem( ...@@ -174,7 +174,6 @@ Future<void> dismissItem(
required AxisDirection gestureDirection, required AxisDirection gestureDirection,
DismissMethod mechanism = dismissElement, DismissMethod mechanism = dismissElement,
}) async { }) async {
assert(gestureDirection != null);
final Finder itemFinder = find.text(item.toString()); final Finder itemFinder = find.text(item.toString());
expect(itemFinder, findsOneWidget); expect(itemFinder, findsOneWidget);
...@@ -188,7 +187,6 @@ Future<void> dragItem( ...@@ -188,7 +187,6 @@ Future<void> dragItem(
required AxisDirection gestureDirection, required AxisDirection gestureDirection,
required double amount, required double amount,
}) async { }) async {
assert(gestureDirection != null);
final Finder itemFinder = find.text(item.toString()); final Finder itemFinder = find.text(item.toString());
expect(itemFinder, findsOneWidget); expect(itemFinder, findsOneWidget);
...@@ -202,7 +200,6 @@ Future<void> checkFlingItemBeforeMovementEnd( ...@@ -202,7 +200,6 @@ Future<void> checkFlingItemBeforeMovementEnd(
required AxisDirection gestureDirection, required AxisDirection gestureDirection,
DismissMethod mechanism = rollbackElement, DismissMethod mechanism = rollbackElement,
}) async { }) async {
assert(gestureDirection != null);
final Finder itemFinder = find.text(item.toString()); final Finder itemFinder = find.text(item.toString());
expect(itemFinder, findsOneWidget); expect(itemFinder, findsOneWidget);
...@@ -218,7 +215,6 @@ Future<void> checkFlingItemAfterMovement( ...@@ -218,7 +215,6 @@ Future<void> checkFlingItemAfterMovement(
required AxisDirection gestureDirection, required AxisDirection gestureDirection,
DismissMethod mechanism = rollbackElement, DismissMethod mechanism = rollbackElement,
}) async { }) async {
assert(gestureDirection != null);
final Finder itemFinder = find.text(item.toString()); final Finder itemFinder = find.text(item.toString());
expect(itemFinder, findsOneWidget); expect(itemFinder, findsOneWidget);
......
...@@ -15,9 +15,7 @@ import '../painting/image_test_utils.dart'; ...@@ -15,9 +15,7 @@ import '../painting/image_test_utils.dart';
const Duration animationDuration = Duration(milliseconds: 50); const Duration animationDuration = Duration(milliseconds: 50);
class FadeInImageParts { class FadeInImageParts {
const FadeInImageParts(this.fadeInImageElement, this.placeholder, this.target) const FadeInImageParts(this.fadeInImageElement, this.placeholder, this.target);
: assert(fadeInImageElement != null),
assert(target != null);
final ComponentElement fadeInImageElement; final ComponentElement fadeInImageElement;
final FadeInImageElements? placeholder; final FadeInImageElements? placeholder;
......
...@@ -1810,9 +1810,7 @@ class Decorate extends StatefulWidget { ...@@ -1810,9 +1810,7 @@ class Decorate extends StatefulWidget {
super.key, super.key,
required this.didChangeDependencies, required this.didChangeDependencies,
required this.build, required this.build,
}) : });
assert(didChangeDependencies != null),
assert(build != null);
final void Function(bool isInBuild) didChangeDependencies; final void Function(bool isInBuild) didChangeDependencies;
final void Function(bool isInBuild) build; final void Function(bool isInBuild) build;
...@@ -1974,7 +1972,7 @@ class StatelessWidgetSpy extends StatelessWidget { ...@@ -1974,7 +1972,7 @@ class StatelessWidgetSpy extends StatelessWidget {
const StatelessWidgetSpy({ const StatelessWidgetSpy({
super.key, super.key,
required this.onBuild, required this.onBuild,
}) : assert(onBuild != null); });
final void Function(BuildContext) onBuild; final void Function(BuildContext) onBuild;
......
...@@ -725,9 +725,7 @@ class _RenderTestLayoutPerformer extends RenderBox { ...@@ -725,9 +725,7 @@ class _RenderTestLayoutPerformer extends RenderBox {
@override @override
void performLayout() { void performLayout() {
size = const Size(1, 1); size = const Size(1, 1);
if (_performLayout != null) { _performLayout();
_performLayout();
}
} }
} }
......
...@@ -205,7 +205,6 @@ class FakeWindowPadding implements WindowPadding { ...@@ -205,7 +205,6 @@ class FakeWindowPadding implements WindowPadding {
Future<void> main() async { Future<void> main() async {
final ui.Image testImage = await createTestImage(); final ui.Image testImage = await createTestImage();
assert(testImage != null);
setUp(() { setUp(() {
transitionFromUserGestures = false; transitionFromUserGestures = false;
......
...@@ -89,7 +89,6 @@ class TestAssetImage extends AssetImage { ...@@ -89,7 +89,6 @@ class TestAssetImage extends AssetImage {
late ImageInfo imageInfo; late ImageInfo imageInfo;
key.bundle.load(key.name).then<void>((ByteData data) { key.bundle.load(key.name).then<void>((ByteData data) {
final ui.Image image = images[scaleOf(data)]!; final ui.Image image = images[scaleOf(data)]!;
assert(image != null, 'Expected ${scaleOf(data)} to have a key in $images');
imageInfo = ImageInfo(image: image, scale: key.scale); imageInfo = ImageInfo(image: image, scale: key.scale);
}); });
return FakeImageStreamCompleter( return FakeImageStreamCompleter(
......
...@@ -2031,9 +2031,7 @@ void main() { ...@@ -2031,9 +2031,7 @@ void main() {
@immutable @immutable
class _ConfigurationAwareKey { class _ConfigurationAwareKey {
const _ConfigurationAwareKey(this.provider, this.configuration) const _ConfigurationAwareKey(this.provider, this.configuration);
: assert(provider != null),
assert(configuration != null);
final ImageProvider provider; final ImageProvider provider;
final ImageConfiguration configuration; final ImageConfiguration configuration;
...@@ -2184,11 +2182,7 @@ class _FailingImageProvider extends ImageProvider<int> { ...@@ -2184,11 +2182,7 @@ class _FailingImageProvider extends ImageProvider<int> {
this.failOnLoad = false, this.failOnLoad = false,
required this.throws, required this.throws,
required this.image, required this.image,
}) : assert(failOnLoad != null), }) : assert(failOnLoad == true || failOnObtainKey == true);
assert(failOnObtainKey != null),
assert(failOnLoad == true || failOnObtainKey == true),
assert(throws != null),
assert(image != null);
final bool failOnObtainKey; final bool failOnObtainKey;
final bool failOnLoad; final bool failOnLoad;
......
...@@ -31,7 +31,7 @@ class ABCModel extends InheritedModel<String> { ...@@ -31,7 +31,7 @@ class ABCModel extends InheritedModel<String> {
@override @override
bool isSupportedAspect(Object aspect) { bool isSupportedAspect(Object aspect) {
return aspect == null || aspects == null || aspects!.contains(aspect); return aspects == null || aspects!.contains(aspect);
} }
@override @override
......
...@@ -16,7 +16,7 @@ class Wrapper extends StatelessWidget { ...@@ -16,7 +16,7 @@ class Wrapper extends StatelessWidget {
const Wrapper({ const Wrapper({
super.key, super.key,
required this.child, required this.child,
}) : assert(child != null); });
final Widget child; final Widget child;
......
...@@ -111,7 +111,7 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext { ...@@ -111,7 +111,7 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext {
required super.context, required super.context,
required double super.initialPixels, required double super.initialPixels,
super.oldPosition, super.oldPosition,
}) : assert(owner != null); });
final LinkedScrollController owner; final LinkedScrollController owner;
......
...@@ -662,7 +662,6 @@ void main() { ...@@ -662,7 +662,6 @@ void main() {
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
Widget buildListView({ required Axis scrollDirection }) { Widget buildListView({ required Axis scrollDirection }) {
assert(scrollDirection != null);
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Center( child: Center(
......
...@@ -1930,7 +1930,7 @@ class _HoverClientWithClosuresState extends State<_HoverClientWithClosures> { ...@@ -1930,7 +1930,7 @@ class _HoverClientWithClosuresState extends State<_HoverClientWithClosures> {
class _ColumnContainer extends StatelessWidget { class _ColumnContainer extends StatelessWidget {
const _ColumnContainer({ const _ColumnContainer({
required this.children, required this.children,
}) : assert(children != null); });
final List<Widget> children; final List<Widget> children;
......
...@@ -390,7 +390,7 @@ List<PlatformMenuItem> createTestMenus({ ...@@ -390,7 +390,7 @@ List<PlatformMenuItem> createTestMenus({
} }
class FakeMenuChannel implements MethodChannel { class FakeMenuChannel implements MethodChannel {
FakeMenuChannel(this.outgoing) : assert(outgoing != null); FakeMenuChannel(this.outgoing);
Future<dynamic> Function(MethodCall) outgoing; Future<dynamic> Function(MethodCall) outgoing;
Future<void> Function(MethodCall)? incoming; Future<void> Function(MethodCall)? incoming;
......
...@@ -113,7 +113,6 @@ class SwapperElementWithProperOverrides extends SwapperElement { ...@@ -113,7 +113,6 @@ class SwapperElementWithProperOverrides extends SwapperElement {
@override @override
void insertRenderObjectChild(RenderBox child, Object? slot) { void insertRenderObjectChild(RenderBox child, Object? slot) {
insertSlots.add(slot); insertSlots.add(slot);
assert(child != null);
if (slot == 'stable') { if (slot == 'stable') {
renderObject.stable = child; renderObject.stable = child;
} else { } else {
......
...@@ -778,7 +778,7 @@ testWidgets('ChildBackButtonDispatcher take priority recursively', (WidgetTester ...@@ -778,7 +778,7 @@ testWidgets('ChildBackButtonDispatcher take priority recursively', (WidgetTester
final SimpleRouterDelegate delegate = SimpleRouterDelegate( final SimpleRouterDelegate delegate = SimpleRouterDelegate(
builder: (BuildContext context, RouteInformation? information) { builder: (BuildContext context, RouteInformation? information) {
final List<Widget> children = <Widget>[]; final List<Widget> children = <Widget>[];
if (information!.location! != null) { if (information!.location != null) {
children.add(Text(information.location!)); children.add(Text(information.location!));
} }
if (information.state != null) { if (information.state != null) {
......
...@@ -48,7 +48,6 @@ void main() { ...@@ -48,7 +48,6 @@ void main() {
} }
Widget buildWidget({ required String blockedText, bool blocking = true }) { Widget buildWidget({ required String blockedText, bool blocking = true }) {
assert(blockedText != null);
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Stack( child: Stack(
......
...@@ -53,12 +53,6 @@ class TestSemantics { ...@@ -53,12 +53,6 @@ class TestSemantics {
Iterable<SemanticsTag>? tags, Iterable<SemanticsTag>? tags,
}) : assert(flags is int || flags is List<SemanticsFlag>), }) : assert(flags is int || flags is List<SemanticsFlag>),
assert(actions is int || actions is List<SemanticsAction>), assert(actions is int || actions is List<SemanticsAction>),
assert(label != null),
assert(value != null),
assert(increasedValue != null),
assert(decreasedValue != null),
assert(hint != null),
assert(children != null),
tags = tags?.toSet() ?? <SemanticsTag>{}; tags = tags?.toSet() ?? <SemanticsTag>{};
/// Creates an object with some test semantics data, with the [id] and [rect] /// Creates an object with some test semantics data, with the [id] and [rect]
...@@ -82,15 +76,9 @@ class TestSemantics { ...@@ -82,15 +76,9 @@ class TestSemantics {
}) : id = 0, }) : id = 0,
assert(flags is int || flags is List<SemanticsFlag>), assert(flags is int || flags is List<SemanticsFlag>),
assert(actions is int || actions is List<SemanticsAction>), assert(actions is int || actions is List<SemanticsAction>),
assert(label != null),
assert(increasedValue != null),
assert(decreasedValue != null),
assert(value != null),
assert(hint != null),
rect = TestSemantics.rootRect, rect = TestSemantics.rootRect,
elevation = 0.0, elevation = 0.0,
thickness = 0.0, thickness = 0.0,
assert(children != null),
tags = tags?.toSet() ?? <SemanticsTag>{}; tags = tags?.toSet() ?? <SemanticsTag>{};
/// Creates an object with some test semantics data, with the [id] and [rect] /// Creates an object with some test semantics data, with the [id] and [rect]
...@@ -125,13 +113,7 @@ class TestSemantics { ...@@ -125,13 +113,7 @@ class TestSemantics {
Iterable<SemanticsTag>? tags, Iterable<SemanticsTag>? tags,
}) : assert(flags is int || flags is List<SemanticsFlag>), }) : assert(flags is int || flags is List<SemanticsFlag>),
assert(actions is int || actions is List<SemanticsAction>), assert(actions is int || actions is List<SemanticsAction>),
assert(label != null),
assert(value != null),
assert(increasedValue != null),
assert(decreasedValue != null),
assert(hint != null),
transform = _applyRootChildScale(transform), transform = _applyRootChildScale(transform),
assert(children != null),
tags = tags?.toSet() ?? <SemanticsTag>{}; tags = tags?.toSet() ?? <SemanticsTag>{};
/// The unique identifier for this node. /// The unique identifier for this node.
...@@ -381,22 +363,22 @@ class TestSemantics { ...@@ -381,22 +363,22 @@ class TestSemantics {
if (actions is int && actions != 0 || actions is List<SemanticsAction> && (actions as List<SemanticsAction>).isNotEmpty) { if (actions is int && actions != 0 || actions is List<SemanticsAction> && (actions as List<SemanticsAction>).isNotEmpty) {
buf.writeln('$indent actions: ${SemanticsTester._actionsToSemanticsActionExpression(actions)},'); buf.writeln('$indent actions: ${SemanticsTester._actionsToSemanticsActionExpression(actions)},');
} }
if (label != null && label != '') { if (label != '') {
buf.writeln("$indent label: '$label',"); buf.writeln("$indent label: '$label',");
} }
if (value != null && value != '') { if (value != '') {
buf.writeln("$indent value: '$value',"); buf.writeln("$indent value: '$value',");
} }
if (increasedValue != null && increasedValue != '') { if (increasedValue != '') {
buf.writeln("$indent increasedValue: '$increasedValue',"); buf.writeln("$indent increasedValue: '$increasedValue',");
} }
if (decreasedValue != null && decreasedValue != '') { if (decreasedValue != '') {
buf.writeln("$indent decreasedValue: '$decreasedValue',"); buf.writeln("$indent decreasedValue: '$decreasedValue',");
} }
if (hint != null && hint != '') { if (hint != '') {
buf.writeln("$indent hint: '$hint',"); buf.writeln("$indent hint: '$hint',");
} }
if (tooltip != null && tooltip != '') { if (tooltip != '') {
buf.writeln("$indent tooltip: '$tooltip',"); buf.writeln("$indent tooltip: '$tooltip',");
} }
if (textDirection != null) { if (textDirection != null) {
...@@ -690,21 +672,21 @@ class SemanticsTester { ...@@ -690,21 +672,21 @@ class SemanticsTester {
if (nodeData.actions != 0) { if (nodeData.actions != 0) {
buf.writeln(' actions: ${_actionsToSemanticsActionExpression(nodeData.actions)},'); buf.writeln(' actions: ${_actionsToSemanticsActionExpression(nodeData.actions)},');
} }
if (node.label != null && node.label.isNotEmpty) { if (node.label.isNotEmpty) {
// Escape newlines and text directionality control characters. // Escape newlines and text directionality control characters.
final String escapedLabel = node.label.replaceAll('\n', r'\n').replaceAll('\u202a', r'\u202a').replaceAll('\u202c', r'\u202c'); final String escapedLabel = node.label.replaceAll('\n', r'\n').replaceAll('\u202a', r'\u202a').replaceAll('\u202c', r'\u202c');
buf.writeln(" label: '$escapedLabel',"); buf.writeln(" label: '$escapedLabel',");
} }
if (node.value != null && node.value.isNotEmpty) { if (node.value.isNotEmpty) {
buf.writeln(" value: '${node.value}',"); buf.writeln(" value: '${node.value}',");
} }
if (node.increasedValue != null && node.increasedValue.isNotEmpty) { if (node.increasedValue.isNotEmpty) {
buf.writeln(" increasedValue: '${node.increasedValue}',"); buf.writeln(" increasedValue: '${node.increasedValue}',");
} }
if (node.decreasedValue != null && node.decreasedValue.isNotEmpty) { if (node.decreasedValue.isNotEmpty) {
buf.writeln(" decreasedValue: '${node.decreasedValue}',"); buf.writeln(" decreasedValue: '${node.decreasedValue}',");
} }
if (node.hint != null && node.hint.isNotEmpty) { if (node.hint.isNotEmpty) {
buf.writeln(" hint: '${node.hint}',"); buf.writeln(" hint: '${node.hint}',");
} }
if (node.textDirection != null) { if (node.textDirection != null) {
...@@ -732,11 +714,7 @@ class _HasSemantics extends Matcher { ...@@ -732,11 +714,7 @@ class _HasSemantics extends Matcher {
required this.ignoreTransform, required this.ignoreTransform,
required this.ignoreId, required this.ignoreId,
required this.childOrder, required this.childOrder,
}) : assert(_semantics != null), });
assert(ignoreRect != null),
assert(ignoreId != null),
assert(ignoreTransform != null),
assert(childOrder != null);
final TestSemantics _semantics; final TestSemantics _semantics;
final bool ignoreRect; final bool ignoreRect;
......
...@@ -1908,7 +1908,7 @@ class _TestCallbackRegistrationState extends State<TestCallbackRegistration> { ...@@ -1908,7 +1908,7 @@ class _TestCallbackRegistrationState extends State<TestCallbackRegistration> {
class TestAction extends CallbackAction<Intent> { class TestAction extends CallbackAction<Intent> {
TestAction({ TestAction({
required super.onInvoke, required super.onInvoke,
}) : assert(onInvoke != null); });
static const LocalKey key = ValueKey<Type>(TestAction); static const LocalKey key = ValueKey<Type>(TestAction);
} }
......
...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; ...@@ -7,7 +7,7 @@ import 'package:flutter/material.dart';
typedef Logger = void Function(String caller); typedef Logger = void Function(String caller);
class TestBorder extends ShapeBorder { class TestBorder extends ShapeBorder {
const TestBorder(this.onLog) : assert(onLog != null); const TestBorder(this.onLog);
final Logger onLog; final Logger onLog;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment