From efbde443d2a6f810d0ceb6097fc79ed0b30bddce Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Thu, 18 Mar 2021 13:40:08 -0700 Subject: [PATCH] Clean up ignores that are not ignoring anything (#78484) --- .../flutter/lib/src/animation/curves.dart | 1 - .../flutter/lib/src/cupertino/colors.dart | 1 - packages/flutter/lib/src/cupertino/icons.dart | 1 - packages/flutter/lib/src/cupertino/route.dart | 5 +---- .../src/cupertino/text_selection_toolbar.dart | 3 +-- .../flutter/lib/src/foundation/isolates.dart | 4 +--- .../flutter/lib/src/foundation/licenses.dart | 1 - .../flutter/lib/src/foundation/unicode.dart | 1 - .../flutter/lib/src/gestures/converter.dart | 1 - packages/flutter/lib/src/material/chip.dart | 6 ------ packages/flutter/lib/src/material/colors.dart | 1 - .../lib/src/material/elevation_overlay.dart | 1 - .../flutter/lib/src/material/feedback.dart | 1 - packages/flutter/lib/src/material/icons.dart | 1 - .../lib/src/material/refresh_indicator.dart | 5 +---- .../lib/src/painting/_network_image_web.dart | 2 +- .../lib/src/painting/image_provider.dart | 5 +---- .../lib/src/painting/matrix_utils.dart | 1 - .../flutter/lib/src/painting/text_span.dart | 7 ++----- packages/flutter/lib/src/rendering/box.dart | 20 ++++--------------- .../lib/src/rendering/custom_layout.dart | 5 +---- .../flutter/lib/src/rendering/proxy_box.dart | 5 +---- .../flutter/lib/src/rendering/viewport.dart | 1 - .../lib/src/semantics/semantics_service.dart | 1 - .../lib/src/services/asset_bundle.dart | 5 +---- .../flutter/lib/src/services/clipboard.dart | 1 - .../lib/src/services/haptic_feedback.dart | 1 - .../lib/src/services/system_channels.dart | 1 - .../lib/src/services/system_chrome.dart | 1 - .../lib/src/services/system_navigator.dart | 1 - .../lib/src/services/system_sound.dart | 1 - .../flutter/lib/src/widgets/framework.dart | 2 +- .../flutter/lib/src/widgets/navigator.dart | 2 +- .../flutter/lib/src/widgets/scroll_view.dart | 2 +- .../test/material/elevated_button_test.dart | 12 ++++++----- .../test/material/outlined_button_test.dart | 12 ++++++----- .../test/material/text_button_test.dart | 11 ++++++---- .../test/material/time_picker_test.dart | 4 ++-- .../flutter/test/material/will_pop_test.dart | 2 +- .../test/painting/mocks_for_image_cache.dart | 1 - .../test/painting/system_fonts_test.dart | 6 +++--- .../test/services/text_input_test.dart | 2 +- .../test/widgets/gesture_detector_test.dart | 2 +- .../test/widgets/localizations_test.dart | 2 +- .../flutter/test/widgets/overlay_test.dart | 1 - .../single_child_scroll_view_test.dart | 4 ++-- 46 files changed, 50 insertions(+), 106 deletions(-) diff --git a/packages/flutter/lib/src/animation/curves.dart b/packages/flutter/lib/src/animation/curves.dart index 69251c4825e..801db30749b 100644 --- a/packages/flutter/lib/src/animation/curves.dart +++ b/packages/flutter/lib/src/animation/curves.dart @@ -1304,7 +1304,6 @@ class ElasticInOutCurve extends Curve { class Curves { // This class is not meant to be instatiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element Curves._(); /// A linear animation curve. diff --git a/packages/flutter/lib/src/cupertino/colors.dart b/packages/flutter/lib/src/cupertino/colors.dart index 6dda1874fc5..52bc56572f9 100644 --- a/packages/flutter/lib/src/cupertino/colors.dart +++ b/packages/flutter/lib/src/cupertino/colors.dart @@ -20,7 +20,6 @@ import 'theme.dart'; class CupertinoColors { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element CupertinoColors._(); /// iOS 13's default blue color. Used to indicate active elements such as diff --git a/packages/flutter/lib/src/cupertino/icons.dart b/packages/flutter/lib/src/cupertino/icons.dart index 3bc2123c471..0b4b4f79a6f 100644 --- a/packages/flutter/lib/src/cupertino/icons.dart +++ b/packages/flutter/lib/src/cupertino/icons.dart @@ -33,7 +33,6 @@ import 'package:flutter/widgets.dart'; class CupertinoIcons { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element CupertinoIcons._(); /// The icon font used for Cupertino icons. diff --git a/packages/flutter/lib/src/cupertino/route.dart b/packages/flutter/lib/src/cupertino/route.dart index 12e7f86a67a..51937482856 100644 --- a/packages/flutter/lib/src/cupertino/route.dart +++ b/packages/flutter/lib/src/cupertino/route.dart @@ -211,10 +211,7 @@ mixin CupertinoRouteTransitionMixin on PageRoute { child: child, ); assert(() { - // `child` has a non-nullable return type, but might be null when - // running with weak checking, so we need to null check it anyway (and - // ignore the warning that the null-handling logic is dead code). - if (child == null) { // ignore: dead_code + if (child == null) { throw FlutterError.fromParts([ ErrorSummary('The builder for route "${settings.name}" returned null.'), ErrorDescription('Route builders must never return null.'), diff --git a/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart b/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart index ad39ccd62f9..2f76b403b0e 100644 --- a/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart +++ b/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart @@ -358,8 +358,7 @@ class _CupertinoTextSelectionToolbarContent extends StatefulWidget { required this.toolbarBuilder, required this.children, }) : assert(children != null), - // This ignore is used because .isNotEmpty isn't compatible with const. - assert(children.length > 0), // ignore: prefer_is_empty + assert(children.length > 0), super(key: key); final Offset anchor; diff --git a/packages/flutter/lib/src/foundation/isolates.dart b/packages/flutter/lib/src/foundation/isolates.dart index 619b5176c1c..a5905b41b8b 100644 --- a/packages/flutter/lib/src/foundation/isolates.dart +++ b/packages/flutter/lib/src/foundation/isolates.dart @@ -44,6 +44,4 @@ typedef _ComputeImpl = Future Function(ComputeCallback callback, /// /// The `debugLabel` argument can be specified to provide a name to add to the /// [Timeline]. This is useful when profiling an application. -// Remove when https://github.com/dart-lang/sdk/issues/37149 is fixed. -// ignore: prefer_const_declarations -final _ComputeImpl compute = _isolates.compute; +const _ComputeImpl compute = _isolates.compute; diff --git a/packages/flutter/lib/src/foundation/licenses.dart b/packages/flutter/lib/src/foundation/licenses.dart index 346c4c852d6..7983ba3add4 100644 --- a/packages/flutter/lib/src/foundation/licenses.dart +++ b/packages/flutter/lib/src/foundation/licenses.dart @@ -288,7 +288,6 @@ class LicenseEntryWithLineBreaks extends LicenseEntry { class LicenseRegistry { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element LicenseRegistry._(); static List? _collectors; diff --git a/packages/flutter/lib/src/foundation/unicode.dart b/packages/flutter/lib/src/foundation/unicode.dart index 5b78fb70804..47cae101a0e 100644 --- a/packages/flutter/lib/src/foundation/unicode.dart +++ b/packages/flutter/lib/src/foundation/unicode.dart @@ -13,7 +13,6 @@ class Unicode { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element Unicode._(); /// `U+202A LEFT-TO-RIGHT EMBEDDING` /// diff --git a/packages/flutter/lib/src/gestures/converter.dart b/packages/flutter/lib/src/gestures/converter.dart index 901e7b3b44e..504dae2f842 100644 --- a/packages/flutter/lib/src/gestures/converter.dart +++ b/packages/flutter/lib/src/gestures/converter.dart @@ -35,7 +35,6 @@ int _synthesiseDownButtons(int buttons, PointerDeviceKind kind) { class PointerEventConverter { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element PointerEventConverter._(); /// Expand the given packet of pointer data into a sequence of framework diff --git a/packages/flutter/lib/src/material/chip.dart b/packages/flutter/lib/src/material/chip.dart index 85d2944d8be..6422726f8d7 100644 --- a/packages/flutter/lib/src/material/chip.dart +++ b/packages/flutter/lib/src/material/chip.dart @@ -62,7 +62,6 @@ const Icon _kDefaultDeleteIcon = Icon(Icons.cancel, size: _kDeleteIconSize); abstract class ChipAttributes { // This class is intended to be used as an interface, and should not be // extended directly; this constructor prevents instantiation and extension. - // ignore: unused_element ChipAttributes._(); /// The primary content of the chip. @@ -203,7 +202,6 @@ abstract class ChipAttributes { abstract class DeletableChipAttributes { // This class is intended to be used as an interface, and should not be // extended directly; this constructor prevents instantiation and extension. - // ignore: unused_element DeletableChipAttributes._(); /// The icon displayed when [onDeleted] is set. @@ -315,7 +313,6 @@ abstract class DeletableChipAttributes { abstract class CheckmarkableChipAttributes { // This class is intended to be used as an interface, and should not be // extended directly; this constructor prevents instantiation and extension. - // ignore: unused_element CheckmarkableChipAttributes._(); /// Whether or not to show a check mark when @@ -351,7 +348,6 @@ abstract class CheckmarkableChipAttributes { abstract class SelectableChipAttributes { // This class is intended to be used as an interface, and should not be // extended directly; this constructor prevents instantiation and extension. - // ignore: unused_element SelectableChipAttributes._(); /// Whether or not this chip is selected. @@ -462,7 +458,6 @@ abstract class SelectableChipAttributes { abstract class DisabledChipAttributes { // This class is intended to be used as an interface, and should not be // extended directly; this constructor prevents instantiation and extension. - // ignore: unused_element DisabledChipAttributes._(); /// Whether or not this chip is enabled for input. @@ -510,7 +505,6 @@ abstract class DisabledChipAttributes { abstract class TappableChipAttributes { // This class is intended to be used as an interface, and should not be // extended directly; this constructor prevents instantiation and extension. - // ignore: unused_element TappableChipAttributes._(); /// Called when the user taps the chip. diff --git a/packages/flutter/lib/src/material/colors.dart b/packages/flutter/lib/src/material/colors.dart index 3dd11afcb27..b0861f585d4 100644 --- a/packages/flutter/lib/src/material/colors.dart +++ b/packages/flutter/lib/src/material/colors.dart @@ -196,7 +196,6 @@ class MaterialAccentColor extends ColorSwatch { class Colors { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element Colors._(); /// Completely invisible. diff --git a/packages/flutter/lib/src/material/elevation_overlay.dart b/packages/flutter/lib/src/material/elevation_overlay.dart index cc5f20f50ff..cd2e77aa69e 100644 --- a/packages/flutter/lib/src/material/elevation_overlay.dart +++ b/packages/flutter/lib/src/material/elevation_overlay.dart @@ -13,7 +13,6 @@ import 'theme.dart'; class ElevationOverlay { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element ElevationOverlay._(); /// Applies an overlay color to a surface color to indicate diff --git a/packages/flutter/lib/src/material/feedback.dart b/packages/flutter/lib/src/material/feedback.dart index 92c609693f8..49ee6916df2 100644 --- a/packages/flutter/lib/src/material/feedback.dart +++ b/packages/flutter/lib/src/material/feedback.dart @@ -84,7 +84,6 @@ import 'theme.dart'; class Feedback { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element Feedback._(); /// Provides platform-specific feedback for a tap. diff --git a/packages/flutter/lib/src/material/icons.dart b/packages/flutter/lib/src/material/icons.dart index 70bd1dec21e..3c8bec0381e 100644 --- a/packages/flutter/lib/src/material/icons.dart +++ b/packages/flutter/lib/src/material/icons.dart @@ -134,7 +134,6 @@ class _PlatformAdaptiveIcons { class Icons { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element Icons._(); /// A set of platform-adaptive material design icons. diff --git a/packages/flutter/lib/src/material/refresh_indicator.dart b/packages/flutter/lib/src/material/refresh_indicator.dart index d137d7fecbf..9b4d135aca5 100644 --- a/packages/flutter/lib/src/material/refresh_indicator.dart +++ b/packages/flutter/lib/src/material/refresh_indicator.dart @@ -434,10 +434,7 @@ class RefreshIndicatorState extends State with TickerProviderS )); return true; }()); - // `refreshResult` has a non-nullable type, but might be null when - // running with weak checking, so we need to null check it anyway (and - // ignore the warning that the null-handling logic is dead code). - if (refreshResult == null) // ignore: dead_code + if (refreshResult == null) return; refreshResult.whenComplete(() { if (mounted && _mode == _RefreshIndicatorMode.refresh) { diff --git a/packages/flutter/lib/src/painting/_network_image_web.dart b/packages/flutter/lib/src/painting/_network_image_web.dart index 5a20da69136..3dad1446fe0 100644 --- a/packages/flutter/lib/src/painting/_network_image_web.dart +++ b/packages/flutter/lib/src/painting/_network_image_web.dart @@ -92,7 +92,7 @@ class NetworkImage chunkCallback: (int bytes, int total) { chunkEvents.add(ImageChunkEvent( cumulativeBytesLoaded: bytes, expectedTotalBytes: total)); - }) as Future; // ignore: undefined_function + }) as Future; } @override diff --git a/packages/flutter/lib/src/painting/image_provider.dart b/packages/flutter/lib/src/painting/image_provider.dart index db7c1ca69b8..2f24f33a281 100644 --- a/packages/flutter/lib/src/painting/image_provider.dart +++ b/packages/flutter/lib/src/painting/image_provider.dart @@ -674,10 +674,7 @@ abstract class AssetBundleImageProvider extends ImageProvider[ ErrorSummary('TextSpan contains a null child.'), ErrorDescription( @@ -459,7 +456,7 @@ class TextSpan extends InlineSpan { // warning that the null-handling logic is dead code). if (child != null) { return child.toDiagnosticsNode(); - } else { // ignore: dead_code + } else { return DiagnosticsNode.message(''); } }).toList(); diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index 7aed6f7c6e7..a25a197529e 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -1398,10 +1398,7 @@ abstract class RenderBox extends RenderObject { @mustCallSuper double getMinIntrinsicWidth(double height) { assert(() { - // `height` has a non-nullable return type, but might be null when - // running with weak checking, so we need to null check it anyway (and - // ignore the warning that the null-handling logic is dead code). - if (height == null) { // ignore: dead_code + if (height == null) { throw FlutterError.fromParts([ ErrorSummary('The height argument to getMinIntrinsicWidth was null.'), ErrorDescription('The argument to getMinIntrinsicWidth must not be negative or null.'), @@ -1550,10 +1547,7 @@ abstract class RenderBox extends RenderObject { @mustCallSuper double getMaxIntrinsicWidth(double height) { assert(() { - // `height` has a non-nullable return type, but might be null when - // running with weak checking, so we need to null check it anyway (and - // ignore the warning that the null-handling logic is dead code). - if (height == null) { // ignore: dead_code + if (height == null) { throw FlutterError.fromParts([ ErrorSummary('The height argument to getMaxIntrinsicWidth was null.'), ErrorDescription('The argument to getMaxIntrinsicWidth must not be negative or null.'), @@ -1636,10 +1630,7 @@ abstract class RenderBox extends RenderObject { @mustCallSuper double getMinIntrinsicHeight(double width) { assert(() { - // `width` has a non-nullable return type, but might be null when - // running with weak checking, so we need to null check it anyway (and - // ignore the warning that the null-handling logic is dead code). - if (width == null) { // ignore: dead_code + if (width == null) { throw FlutterError.fromParts([ ErrorSummary('The width argument to getMinIntrinsicHeight was null.'), ErrorDescription('The argument to getMinIntrinsicHeight must not be negative or null.'), @@ -1721,10 +1712,7 @@ abstract class RenderBox extends RenderObject { @mustCallSuper double getMaxIntrinsicHeight(double width) { assert(() { - // `width` has a non-nullable return type, but might be null when - // running with weak checking, so we need to null check it anyway (and - // ignore the warning that the null-handling logic is dead code). - if (width == null) { // ignore: dead_code + if (width == null) { throw FlutterError.fromParts([ ErrorSummary('The width argument to getMaxIntrinsicHeight was null.'), ErrorDescription('The argument to getMaxIntrinsicHeight must not be negative or null.'), diff --git a/packages/flutter/lib/src/rendering/custom_layout.dart b/packages/flutter/lib/src/rendering/custom_layout.dart index 3231b53b4ae..1b3383b4b7c 100644 --- a/packages/flutter/lib/src/rendering/custom_layout.dart +++ b/packages/flutter/lib/src/rendering/custom_layout.dart @@ -187,10 +187,7 @@ abstract class MultiChildLayoutDelegate { 'There is no child with the id "$childId".' ); } - // `offset` has a non-nullable return type, but might be null when - // running with weak checking, so we need to null check it anyway (and - // ignore the warning that the null-handling logic is dead code). - if (offset == null) { // ignore: dead_code + if (offset == null) { throw FlutterError( 'The $this custom multichild layout delegate provided a null position for the child with id "$childId".' ); diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 8ad0841525b..f29f20e00d5 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -1499,10 +1499,7 @@ class RenderClipRRect extends _RenderCustomClip { assert(clipBehavior != Clip.none), _borderRadius = borderRadius, super(child: child, clipper: clipper, clipBehavior: clipBehavior) { - // `_borderRadius` has a non-nullable return type, but might be null when - // running with weak checking, so we need to null check it anyway (and - // ignore the warning that the null-handling logic is dead code). - assert(_borderRadius != null || clipper != null);// ignore: dead_code + assert(_borderRadius != null || clipper != null); } /// The border radius of the rounded corners. diff --git a/packages/flutter/lib/src/rendering/viewport.dart b/packages/flutter/lib/src/rendering/viewport.dart index 32d330b69d3..4c3d3ad779f 100644 --- a/packages/flutter/lib/src/rendering/viewport.dart +++ b/packages/flutter/lib/src/rendering/viewport.dart @@ -32,7 +32,6 @@ enum CacheExtentStyle { abstract class RenderAbstractViewport extends RenderObject { // This class is intended to be used as an interface, and should not be // extended directly; this constructor prevents instantiation and extension. - // ignore: unused_element factory RenderAbstractViewport._() => throw Error(); /// Returns the [RenderAbstractViewport] that most tightly encloses the given diff --git a/packages/flutter/lib/src/semantics/semantics_service.dart b/packages/flutter/lib/src/semantics/semantics_service.dart index 13007b1e5af..71af1b00382 100644 --- a/packages/flutter/lib/src/semantics/semantics_service.dart +++ b/packages/flutter/lib/src/semantics/semantics_service.dart @@ -20,7 +20,6 @@ import 'semantics_event.dart' show AnnounceSemanticsEvent, TooltipSemanticsEvent class SemanticsService { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element SemanticsService._(); /// Sends a semantic announcement. diff --git a/packages/flutter/lib/src/services/asset_bundle.dart b/packages/flutter/lib/src/services/asset_bundle.dart index 249f24c726b..527898306c2 100644 --- a/packages/flutter/lib/src/services/asset_bundle.dart +++ b/packages/flutter/lib/src/services/asset_bundle.dart @@ -66,11 +66,8 @@ abstract class AssetBundle { /// implementation.) Future loadString(String key, { bool cache = true }) async { final ByteData data = await load(key); - // Note: data has a non-nullable type, but might be null when running with - // weak checking, so we need to null check it anyway (and ignore the warning - // that the null-handling logic is dead code). if (data == null) - throw FlutterError('Unable to load asset: $key'); // ignore: dead_code + throw FlutterError('Unable to load asset: $key'); // 50 KB of data should take 2-3 ms to parse on a Moto G4, and about 400 μs // on a Pixel 4. if (data.lengthInBytes < 50 * 1024) { diff --git a/packages/flutter/lib/src/services/clipboard.dart b/packages/flutter/lib/src/services/clipboard.dart index bed3d61fb8c..48ae122d07d 100644 --- a/packages/flutter/lib/src/services/clipboard.dart +++ b/packages/flutter/lib/src/services/clipboard.dart @@ -24,7 +24,6 @@ class ClipboardData { class Clipboard { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element Clipboard._(); // Constants for common [getData] [format] types. diff --git a/packages/flutter/lib/src/services/haptic_feedback.dart b/packages/flutter/lib/src/services/haptic_feedback.dart index 523ea13bffd..1d2847a8f49 100644 --- a/packages/flutter/lib/src/services/haptic_feedback.dart +++ b/packages/flutter/lib/src/services/haptic_feedback.dart @@ -12,7 +12,6 @@ import 'system_channels.dart'; class HapticFeedback { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element HapticFeedback._(); /// Provides vibration haptic feedback to the user for a short duration. diff --git a/packages/flutter/lib/src/services/system_channels.dart b/packages/flutter/lib/src/services/system_channels.dart index 46be1806315..43e6bf29f29 100644 --- a/packages/flutter/lib/src/services/system_channels.dart +++ b/packages/flutter/lib/src/services/system_channels.dart @@ -11,7 +11,6 @@ import 'platform_channel.dart'; class SystemChannels { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element SystemChannels._(); /// A JSON [MethodChannel] for navigation. diff --git a/packages/flutter/lib/src/services/system_chrome.dart b/packages/flutter/lib/src/services/system_chrome.dart index 3e15f0f6aeb..0bf42202746 100644 --- a/packages/flutter/lib/src/services/system_chrome.dart +++ b/packages/flutter/lib/src/services/system_chrome.dart @@ -219,7 +219,6 @@ List _stringify(List list) => [ class SystemChrome { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element SystemChrome._(); /// Specifies the set of orientations the application interface can diff --git a/packages/flutter/lib/src/services/system_navigator.dart b/packages/flutter/lib/src/services/system_navigator.dart index 9cd1b9439d9..d7ce5cb1ab0 100644 --- a/packages/flutter/lib/src/services/system_navigator.dart +++ b/packages/flutter/lib/src/services/system_navigator.dart @@ -9,7 +9,6 @@ import 'system_channels.dart'; class SystemNavigator { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element SystemNavigator._(); /// Removes the topmost Flutter instance, presenting what was before diff --git a/packages/flutter/lib/src/services/system_sound.dart b/packages/flutter/lib/src/services/system_sound.dart index 467892729de..55874e9871c 100644 --- a/packages/flutter/lib/src/services/system_sound.dart +++ b/packages/flutter/lib/src/services/system_sound.dart @@ -29,7 +29,6 @@ enum SystemSoundType { class SystemSound { // This class is not meant to be instantiated or extended; this constructor // prevents instantiation and extension. - // ignore: unused_element SystemSound._(); /// Play the specified system sound. If that sound is not present on the diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index e3ce722f744..c85833e666c 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -1745,7 +1745,7 @@ abstract class MultiChildRenderObjectWidget extends RenderObjectWidget { assert(() { for (int index = 0; index < children.length; index++) { // TODO(a14n): remove this check to have a lot more const widget - if (children[index] == null) { // ignore: dead_code + if (children[index] == null) { throw FlutterError( "$runtimeType's children must not contain any null values, " 'but a null value was found at index $index' diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index 801e330b110..f88d407b8fc 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -5355,13 +5355,13 @@ abstract class _RestorationInformation { final List casted = data as List; assert(casted.isNotEmpty); final _RouteRestorationType type = _RouteRestorationType.values[casted[0]! as int]; + assert(type != null); switch (type) { case _RouteRestorationType.named: return _NamedRestorationInformation.fromSerializableData(casted.sublist(1)); case _RouteRestorationType.anonymous: return _AnonymousRestorationInformation.fromSerializableData(casted.sublist(1)); } - throw StateError('Invalid type: $type'); // ignore: dead_code } final _RouteRestorationType type; diff --git a/packages/flutter/lib/src/widgets/scroll_view.dart b/packages/flutter/lib/src/widgets/scroll_view.dart index c25883e78ea..35a18cf8267 100644 --- a/packages/flutter/lib/src/widgets/scroll_view.dart +++ b/packages/flutter/lib/src/widgets/scroll_view.dart @@ -1278,7 +1278,7 @@ class ListView extends BoxScrollView { } else { widget = separatorBuilder(context, itemIndex); assert(() { - if (widget == null) { // ignore: dead_code + if (widget == null) { throw FlutterError('separatorBuilder cannot return null.'); } return true; diff --git a/packages/flutter/test/material/elevated_button_test.dart b/packages/flutter/test/material/elevated_button_test.dart index a3aabbed135..338b07c34e9 100644 --- a/packages/flutter/test/material/elevated_button_test.dart +++ b/packages/flutter/test/material/elevated_button_test.dart @@ -793,11 +793,13 @@ void main() { for (final double textScaleFactor in textScaleFactorOptions) { for (final TextDirection textDirection in textDirectionOptions) { for (final Widget? icon in iconOptions) { - final String testName = 'ElevatedButton' - ', text scale $textScaleFactor' // ignore: missing_whitespace_between_adjacent_strings, https://github.com/dart-lang/linter/issues/2489 - '${icon != null ? ", with icon" : ""}' - '${textDirection == TextDirection.rtl ? ", RTL" : ""}'; - + final String testName = [ + 'ElevatedButton, text scale $textScaleFactor', + if (icon != null) + 'with icon', + if (textDirection == TextDirection.rtl) + 'RTL', + ].join(', '); testWidgets(testName, (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( diff --git a/packages/flutter/test/material/outlined_button_test.dart b/packages/flutter/test/material/outlined_button_test.dart index 7d4505e81a9..4dcd3b82cd9 100644 --- a/packages/flutter/test/material/outlined_button_test.dart +++ b/packages/flutter/test/material/outlined_button_test.dart @@ -1038,11 +1038,13 @@ void main() { for (final double textScaleFactor in textScaleFactorOptions) { for (final TextDirection textDirection in textDirectionOptions) { for (final Widget? icon in iconOptions) { - final String testName = 'OutlinedButton' - ', text scale $textScaleFactor' // ignore: missing_whitespace_between_adjacent_strings, https://github.com/dart-lang/linter/issues/2489 - '${icon != null ? ", with icon" : ""}' - '${textDirection == TextDirection.rtl ? ", RTL" : ""}'; - + final String testName = [ + 'OutlinedButton, text scale $textScaleFactor', + if (icon != null) + 'with icon', + if (textDirection == TextDirection.rtl) + 'RTL', + ].join(', '); testWidgets(testName, (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( diff --git a/packages/flutter/test/material/text_button_test.dart b/packages/flutter/test/material/text_button_test.dart index 3811da48dd9..9ef3bb35de6 100644 --- a/packages/flutter/test/material/text_button_test.dart +++ b/packages/flutter/test/material/text_button_test.dart @@ -831,10 +831,13 @@ void main() { for (final double textScaleFactor in textScaleFactorOptions) { for (final TextDirection textDirection in textDirectionOptions) { for (final Widget? icon in iconOptions) { - final String testName = 'TextButton' - ', text scale $textScaleFactor' // ignore: missing_whitespace_between_adjacent_strings, https://github.com/dart-lang/linter/issues/2489 - '${icon != null ? ", with icon" : ""}' - '${textDirection == TextDirection.rtl ? ", RTL" : ""}'; + final String testName = [ + 'TextButton, text scale $textScaleFactor', + if (icon != null) + 'with icon', + if (textDirection == TextDirection.rtl) + 'RTL', + ].join(', '); testWidgets(testName, (WidgetTester tester) async { await tester.pumpWidget( diff --git a/packages/flutter/test/material/time_picker_test.dart b/packages/flutter/test/material/time_picker_test.dart index 3b94b8483b8..e2175f0eb08 100644 --- a/packages/flutter/test/material/time_picker_test.dart +++ b/packages/flutter/test/material/time_picker_test.dart @@ -427,7 +427,7 @@ void _tests() { ); // Ensure we preserve day period as we roll over. - final dynamic pickerState = tester.state(_timePickerDialog); // ignore: unnecessary_nullable_for_final_variable_declarations + final dynamic pickerState = tester.state(_timePickerDialog); expect(pickerState.selectedTime, const TimeOfDay(hour: 1, minute: 0)); await actAndExpect( @@ -492,7 +492,7 @@ void _tests() { ); // Ensure we preserve hour period as we roll over. - final dynamic pickerState = tester.state(_timePickerDialog); // ignore: unnecessary_nullable_for_final_variable_declarations + final dynamic pickerState = tester.state(_timePickerDialog); expect(pickerState.selectedTime, const TimeOfDay(hour: 11, minute: 0)); await actAndExpect( diff --git a/packages/flutter/test/material/will_pop_test.dart b/packages/flutter/test/material/will_pop_test.dart index 54a21f419c3..9d4f290d24d 100644 --- a/packages/flutter/test/material/will_pop_test.dart +++ b/packages/flutter/test/material/will_pop_test.dart @@ -116,7 +116,7 @@ void main() { // Use didPopRoute() to simulate the system back button. Check that // didPopRoute() indicates that the notification was handled. - final dynamic widgetsAppState = tester.state(find.byType(WidgetsApp)); // ignore: unnecessary_nullable_for_final_variable_declarations + final dynamic widgetsAppState = tester.state(find.byType(WidgetsApp)); expect(await widgetsAppState.didPopRoute(), isTrue); expect(find.text('Sample Page'), findsOneWidget); diff --git a/packages/flutter/test/painting/mocks_for_image_cache.dart b/packages/flutter/test/painting/mocks_for_image_cache.dart index a93b9e53e0a..7049951419e 100644 --- a/packages/flutter/test/painting/mocks_for_image_cache.dart +++ b/packages/flutter/test/painting/mocks_for_image_cache.dart @@ -8,7 +8,6 @@ import 'dart:ui' as ui show Image; import 'package:flutter/foundation.dart'; import 'package:flutter/painting.dart'; -// ignore: must_be_immutable class TestImageInfo implements ImageInfo { const TestImageInfo(this.value, { required this.image, this.scale = 1.0, this.debugLabel }); diff --git a/packages/flutter/test/painting/system_fonts_test.dart b/packages/flutter/test/painting/system_fonts_test.dart index 3019ca9dbc2..e22ff6877af 100644 --- a/packages/flutter/test/painting/system_fonts_test.dart +++ b/packages/flutter/test/painting/system_fonts_test.dart @@ -74,7 +74,7 @@ void main() { ), ), ); - final dynamic state = tester.state(find.byType(CupertinoDatePicker)); // ignore: unnecessary_nullable_for_final_variable_declarations + final dynamic state = tester.state(find.byType(CupertinoDatePicker)); final Map cache = state.estimatedColumnWidths as Map; expect(cache.isNotEmpty, isTrue); const Map data = { @@ -100,7 +100,7 @@ void main() { ), ), ); - final dynamic state = tester.state(find.byType(CupertinoDatePicker)); // ignore: unnecessary_nullable_for_final_variable_declarations + final dynamic state = tester.state(find.byType(CupertinoDatePicker)); final Map cache = state.estimatedColumnWidths as Map; // Simulates font missing. cache.clear(); @@ -126,7 +126,7 @@ void main() { ), ), ); - final dynamic state = tester.state(find.byType(CupertinoTimerPicker)); // ignore: unnecessary_nullable_for_final_variable_declarations + final dynamic state = tester.state(find.byType(CupertinoTimerPicker)); // Simulates wrong metrics due to font missing. state.numberLabelWidth = 0.0; state.numberLabelHeight = 0.0; diff --git a/packages/flutter/test/services/text_input_test.dart b/packages/flutter/test/services/text_input_test.dart index 67ea3287d30..968f5ba7a87 100644 --- a/packages/flutter/test/services/text_input_test.dart +++ b/packages/flutter/test/services/text_input_test.dart @@ -133,7 +133,7 @@ void main() { test('basic structure', () async { const TextInputType text = TextInputType.text; const TextInputType number = TextInputType.number; - const TextInputType number2 = TextInputType.numberWithOptions(); // ignore: use_named_constants + const TextInputType number2 = TextInputType.numberWithOptions(); const TextInputType signed = TextInputType.numberWithOptions(signed: true); const TextInputType signed2 = TextInputType.numberWithOptions(signed: true); const TextInputType decimal = TextInputType.numberWithOptions(decimal: true); diff --git a/packages/flutter/test/widgets/gesture_detector_test.dart b/packages/flutter/test/widgets/gesture_detector_test.dart index 658b8e9fe0f..8514d4f2d6b 100644 --- a/packages/flutter/test/widgets/gesture_detector_test.dart +++ b/packages/flutter/test/widgets/gesture_detector_test.dart @@ -908,7 +908,7 @@ class ButtonVariant extends TestVariant { const ButtonVariant({ required this.values, required this.descriptions, - }) : assert(values.length != 0); // ignore: prefer_is_empty + }) : assert(values.length != 0); @override final List values; diff --git a/packages/flutter/test/widgets/localizations_test.dart b/packages/flutter/test/widgets/localizations_test.dart index 48dd799af7e..7a0692c56a8 100644 --- a/packages/flutter/test/widgets/localizations_test.dart +++ b/packages/flutter/test/widgets/localizations_test.dart @@ -20,7 +20,7 @@ void main() { ], child: const Text('loaded') )); - final dynamic state = tester.state(find.byType(Localizations)); // ignore: unnecessary_nullable_for_final_variable_declarations + final dynamic state = tester.state(find.byType(Localizations)); expect(state!.locale, isNull); expect(find.text('loaded'), findsNothing); diff --git a/packages/flutter/test/widgets/overlay_test.dart b/packages/flutter/test/widgets/overlay_test.dart index 025a0b6fd92..08c0206ff24 100644 --- a/packages/flutter/test/widgets/overlay_test.dart +++ b/packages/flutter/test/widgets/overlay_test.dart @@ -1035,7 +1035,6 @@ void main() { ); // By default, clipBehavior should be Clip.hardEdge - // ignore: unnecessary_nullable_for_final_variable_declarations final dynamic renderObject = tester.renderObject(find.byType(Overlay)); expect(renderObject.clipBehavior, equals(Clip.hardEdge)); diff --git a/packages/flutter/test/widgets/single_child_scroll_view_test.dart b/packages/flutter/test/widgets/single_child_scroll_view_test.dart index 9b2c4326d98..77278e83c01 100644 --- a/packages/flutter/test/widgets/single_child_scroll_view_test.dart +++ b/packages/flutter/test/widgets/single_child_scroll_view_test.dart @@ -50,7 +50,7 @@ void main() { ); // 1st, check that the render object has received the default clip behavior. - final dynamic renderObject = tester.allRenderObjects.where((RenderObject o) => o.runtimeType.toString() == '_RenderSingleChildViewport').first; // ignore: unnecessary_nullable_for_final_variable_declarations + final dynamic renderObject = tester.allRenderObjects.where((RenderObject o) => o.runtimeType.toString() == '_RenderSingleChildViewport').first; expect(renderObject.clipBehavior, equals(Clip.hardEdge)); // 2nd, height == widow.height test: check that the painting context does not call pushClipRect . @@ -104,7 +104,7 @@ void main() { await tester.pumpWidget(SingleChildScrollView(child: Container(height: 2000.0))); // 1st, check that the render object has received the default clip behavior. - final dynamic renderObject = tester.allRenderObjects.where((RenderObject o) => o.runtimeType.toString() == '_RenderSingleChildViewport').first; // ignore: unnecessary_nullable_for_final_variable_declarations + final dynamic renderObject = tester.allRenderObjects.where((RenderObject o) => o.runtimeType.toString() == '_RenderSingleChildViewport').first; expect(renderObject.clipBehavior, equals(Clip.hardEdge)); // 2nd, check that the painting context has received the default clip behavior.