From 5e1ba701ed9fd387bafb830a030f2ba56507e2a7 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Tue, 16 May 2023 18:14:23 +0200 Subject: [PATCH] enable no_literal_bool_comparisons lint (#126647) --- analysis_options.yaml | 2 +- dev/bots/test.dart | 2 +- dev/conductor/core/lib/src/codesign.dart | 2 +- dev/conductor/core/lib/src/next.dart | 14 +++++++------- dev/devicelab/bin/run.dart | 4 ++-- packages/flutter/lib/src/cupertino/nav_bar.dart | 2 +- .../flutter/lib/src/foundation/assertions.dart | 2 +- .../flutter/lib/src/foundation/diagnostics.dart | 2 +- packages/flutter/lib/src/gestures/events.dart | 6 +++--- .../flutter/lib/src/gestures/long_press.dart | 2 +- packages/flutter/lib/src/gestures/multitap.dart | 2 +- packages/flutter/lib/src/material/chip.dart | 10 +++++----- .../lib/src/material/selectable_text.dart | 2 +- .../flutter/lib/src/material/slider_theme.dart | 4 ++-- .../flutter/lib/src/material/text_field.dart | 2 +- packages/flutter/lib/src/painting/debug.dart | 2 +- .../flutter/lib/src/painting/inline_span.dart | 2 +- .../src/rendering/sliver_multi_box_adaptor.dart | 2 +- .../flutter/lib/src/services/platform_views.dart | 4 ++-- packages/flutter/lib/src/widgets/actions.dart | 2 +- packages/flutter/lib/src/widgets/routes.dart | 2 +- packages/flutter/lib/src/widgets/visibility.dart | 16 ++++++++-------- .../lib/src/widgets/widget_inspector.dart | 4 ++-- packages/flutter/test/widgets/image_test.dart | 2 +- packages/flutter_test/lib/src/widget_tester.dart | 4 ++-- packages/flutter_tools/lib/src/base/build.dart | 2 +- packages/flutter_tools/lib/src/base/logger.dart | 2 +- .../lib/src/commands/custom_devices.dart | 4 ++-- packages/flutter_tools/lib/src/compile.dart | 2 +- .../lib/src/custom_devices/custom_device.dart | 4 ++-- .../flutter_tools/lib/src/desktop_device.dart | 2 +- packages/flutter_tools/lib/src/device.dart | 4 ++-- packages/flutter_tools/lib/src/doctor.dart | 2 +- packages/flutter_tools/lib/src/emulator.dart | 4 ++-- packages/flutter_tools/lib/src/ios/devices.dart | 2 +- .../flutter_tools/lib/src/ios/xcodeproj.dart | 4 ++-- .../cmake_custom_command_migration.dart | 2 +- .../lib/src/proxied_devices/devices.dart | 2 +- .../lib/src/runner/flutter_command.dart | 2 +- .../flutter_tools/lib/src/xcode_project.dart | 2 +- .../hermetic/analyze_continuously_test.dart | 6 +++--- .../test/commands.shard/hermetic/clean_test.dart | 2 +- .../hermetic/create_usage_test.dart | 2 +- .../test/commands.shard/hermetic/run_test.dart | 4 ++-- .../test/general.shard/args_test.dart | 2 +- .../test/general.shard/channel_test.dart | 4 ++-- 46 files changed, 79 insertions(+), 79 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index e4ccec5d6b..1eab21a224 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -127,7 +127,7 @@ linter: - no_duplicate_case_values - no_leading_underscores_for_library_prefixes - no_leading_underscores_for_local_identifiers - # - no_literal_bool_comparisons # needs quick fix, https://github.com/dart-lang/linter/issues/4333 + - no_literal_bool_comparisons - no_logic_in_create_state # - no_runtimeType_toString # ok in tests; we enable this only in packages/ - non_constant_identifier_names diff --git a/dev/bots/test.dart b/dev/bots/test.dart index e9aca1b731..a125356ca1 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -809,7 +809,7 @@ Future _runFrameworkTests() async { final List tests = Directory(path.join(flutterRoot, 'packages', 'flutter', 'test')) .listSync(followLinks: false) .whereType() - .where((Directory dir) => dir.path.endsWith('widgets') == false) + .where((Directory dir) => !dir.path.endsWith('widgets')) .map((Directory dir) => path.join('test', path.basename(dir.path)) + path.separator) .toList(); printProgress('${green}Running packages/flutter tests$reset for $cyan${tests.join(", ")}$reset'); diff --git a/dev/conductor/core/lib/src/codesign.dart b/dev/conductor/core/lib/src/codesign.dart index 54d553ac2d..c5cf2038a6 100644 --- a/dev/conductor/core/lib/src/codesign.dart +++ b/dev/conductor/core/lib/src/codesign.dart @@ -99,7 +99,7 @@ class CodesignCommand extends Command { ); } - if (argResults!['verify'] as bool != true) { + if (!(argResults!['verify'] as bool)) { throw ConductorException( 'Sorry, but codesigning is not implemented yet. Please pass the ' '--$kVerify flag to verify signatures.', diff --git a/dev/conductor/core/lib/src/next.dart b/dev/conductor/core/lib/src/next.dart index 8f3417acfb..0df5615cc4 100644 --- a/dev/conductor/core/lib/src/next.dart +++ b/dev/conductor/core/lib/src/next.dart @@ -128,7 +128,7 @@ class NextContext extends Context { stdio.printStatus('These must be applied manually in the directory ' '${state.engine.checkoutPath} before proceeding.\n'); } - if (autoAccept == false) { + if (!autoAccept) { final bool response = await prompt( 'Are you ready to push your engine branch to the repository ' '${state.engine.mirror.url}?', @@ -146,7 +146,7 @@ class NextContext extends Context { 'You must validate pre-submit CI for your engine PR, merge it, and codesign', 'binaries before proceeding.\n', ].join('\n')); - if (autoAccept == false) { + if (!autoAccept) { // TODO(fujino): actually test if binaries have been codesigned on macOS final bool response = await prompt( 'Has CI passed for the engine PR and binaries been codesigned?', @@ -236,7 +236,7 @@ class NextContext extends Context { ); } - if (autoAccept == false) { + if (!autoAccept) { final bool response = await prompt( 'Are you ready to push your framework branch to the repository ' '${state.framework.mirror.url}?', @@ -276,7 +276,7 @@ class NextContext extends Context { previousCheckoutLocation: state.engine.checkoutPath, ); final String engineHead = await engine.reverseParse('HEAD'); - if (autoAccept == false) { + if (!autoAccept) { final bool response = await prompt( 'Are you ready to tag commit $frameworkHead as ${state.releaseVersion}\n' 'and push to remote ${state.framework.upstream.url}?', @@ -302,7 +302,7 @@ class NextContext extends Context { previousCheckoutLocation: state.framework.checkoutPath, ); final String headRevision = await framework.reverseParse('HEAD'); - if (autoAccept == false) { + if (!autoAccept) { // dryRun: true means print out git command await framework.pushRef( fromRef: headRevision, @@ -332,7 +332,7 @@ class NextContext extends Context { 'The current status of packaging builds can be seen at:\n' '\t$kLuciPackagingConsoleLink', ); - if (autoAccept == false) { + if (!autoAccept) { final bool response = await prompt( 'Have all packaging builds finished successfully and post release announcements been completed?'); if (!response) { @@ -373,7 +373,7 @@ class NextContext extends Context { force: force, ); } on GitException catch (exception) { - if (exception.type == GitExceptionType.PushRejected && force == false) { + if (exception.type == GitExceptionType.PushRejected && !force) { throw ConductorException( 'Push failed because the working branch named ' '${pbRepository.workingBranch} already exists on your mirror. ' diff --git a/dev/devicelab/bin/run.dart b/dev/devicelab/bin/run.dart index 1a13762b27..cc0cb1bb29 100644 --- a/dev/devicelab/bin/run.dart +++ b/dev/devicelab/bin/run.dart @@ -176,7 +176,7 @@ Future _runABTest({ abTest.addBResult(localEngineResult); - if (silent != true && i < runsPerTest) { + if (!silent && i < runsPerTest) { section('A/B results so far'); print(abTest.printSummary()); } @@ -186,7 +186,7 @@ Future _runABTest({ final File jsonFile = _uniqueFile(resultsFile); jsonFile.writeAsStringSync(const JsonEncoder.withIndent(' ').convert(abTest.jsonMap)); - if (silent != true) { + if (!silent) { section('Raw results'); print(abTest.rawResults()); } diff --git a/packages/flutter/lib/src/cupertino/nav_bar.dart b/packages/flutter/lib/src/cupertino/nav_bar.dart index f82ca74e3a..f33ea8d95c 100644 --- a/packages/flutter/lib/src/cupertino/nav_bar.dart +++ b/packages/flutter/lib/src/cupertino/nav_bar.dart @@ -602,7 +602,7 @@ class CupertinoSliverNavigationBar extends StatefulWidget { this.heroTag = _defaultHeroTag, this.stretch = false, }) : assert( - automaticallyImplyTitle == true || largeTitle != null, + automaticallyImplyTitle || largeTitle != null, 'No largeTitle has been provided but automaticallyImplyTitle is also ' 'false. Either provide a largeTitle or set automaticallyImplyTitle to ' 'true.', diff --git a/packages/flutter/lib/src/foundation/assertions.dart b/packages/flutter/lib/src/foundation/assertions.dart index 3072ee051c..0ee4130334 100644 --- a/packages/flutter/lib/src/foundation/assertions.dart +++ b/packages/flutter/lib/src/foundation/assertions.dart @@ -1009,7 +1009,7 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti isInDebugMode = true; return true; }()); - final bool reportError = isInDebugMode || details.silent != true; // could be null + final bool reportError = isInDebugMode || !details.silent; // could be null if (!reportError && !forceReport) { return; } diff --git a/packages/flutter/lib/src/foundation/diagnostics.dart b/packages/flutter/lib/src/foundation/diagnostics.dart index 09f49b1d20..280a8818d1 100644 --- a/packages/flutter/lib/src/foundation/diagnostics.dart +++ b/packages/flutter/lib/src/foundation/diagnostics.dart @@ -1616,7 +1616,7 @@ abstract class DiagnosticsNode { 'showSeparator': showSeparator, if (level != DiagnosticLevel.info) 'level': level.name, - if (showName == false) + if (!showName) 'showName': showName, if (emptyBodyDescription != null) 'emptyBodyDescription': emptyBodyDescription, diff --git a/packages/flutter/lib/src/gestures/events.dart b/packages/flutter/lib/src/gestures/events.dart index 2af7575401..1a1b5f2b57 100644 --- a/packages/flutter/lib/src/gestures/events.dart +++ b/packages/flutter/lib/src/gestures/events.dart @@ -205,9 +205,9 @@ int smallestButton(int buttons) => buttons & (-buttons); /// Example: /// /// ```dart -/// assert(isSingleButton(0x1) == true); -/// assert(isSingleButton(0x11) == false); -/// assert(isSingleButton(0) == false); +/// assert(isSingleButton(0x1)); +/// assert(!isSingleButton(0x11)); +/// assert(!isSingleButton(0)); /// ``` /// /// See also: diff --git a/packages/flutter/lib/src/gestures/long_press.dart b/packages/flutter/lib/src/gestures/long_press.dart index 247947df92..91a11c781a 100644 --- a/packages/flutter/lib/src/gestures/long_press.dart +++ b/packages/flutter/lib/src/gestures/long_press.dart @@ -629,7 +629,7 @@ class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer { } if (event is PointerUpEvent) { - if (_longPressAccepted == true) { + if (_longPressAccepted) { _checkLongPressEnd(event); } else { // Pointer is lifted before timeout. diff --git a/packages/flutter/lib/src/gestures/multitap.dart b/packages/flutter/lib/src/gestures/multitap.dart index 1c2292b3a4..2c9b6f5c31 100644 --- a/packages/flutter/lib/src/gestures/multitap.dart +++ b/packages/flutter/lib/src/gestures/multitap.dart @@ -208,7 +208,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer { // If second tap is not allowed, reset the state. final bool isPointerAllowed = super.isPointerAllowed(event); - if (isPointerAllowed == false) { + if (!isPointerAllowed) { _reset(); } return isPointerAllowed; diff --git a/packages/flutter/lib/src/material/chip.dart b/packages/flutter/lib/src/material/chip.dart index 614856573d..e794ef3b0a 100644 --- a/packages/flutter/lib/src/material/chip.dart +++ b/packages/flutter/lib/src/material/chip.dart @@ -875,7 +875,7 @@ class _RawChipState extends State with MaterialStateMixin, TickerProvid setMaterialState(MaterialState.selected, widget.selected); selectController = AnimationController( duration: _kSelectDuration, - value: widget.selected == true ? 1.0 : 0.0, + value: widget.selected ? 1.0 : 0.0, vsync: this, ); selectionFade = CurvedAnimation( @@ -884,7 +884,7 @@ class _RawChipState extends State with MaterialStateMixin, TickerProvid ); avatarDrawerController = AnimationController( duration: _kDrawerDuration, - value: hasAvatar || widget.selected == true ? 1.0 : 0.0, + value: hasAvatar || widget.selected ? 1.0 : 0.0, vsync: this, ); deleteDrawerController = AnimationController( @@ -1042,7 +1042,7 @@ class _RawChipState extends State with MaterialStateMixin, TickerProvid } if (oldWidget.avatar != widget.avatar || oldWidget.selected != widget.selected) { setState(() { - if (hasAvatar || widget.selected == true) { + if (hasAvatar || widget.selected) { avatarDrawerController.forward(); } else { avatarDrawerController.reverse(); @@ -1052,7 +1052,7 @@ class _RawChipState extends State with MaterialStateMixin, TickerProvid if (oldWidget.selected != widget.selected) { setState(() { setMaterialState(MaterialState.selected, widget.selected); - if (widget.selected == true) { + if (widget.selected) { selectController.forward(); } else { selectController.reverse(); @@ -1979,7 +1979,7 @@ class _RenderChip extends RenderBox with SlottedContainerRenderObjectMixin<_Chip _paintSelectionOverlay(context, offset); } - if (theme.showAvatar == false && avatarDrawerAnimation.isDismissed) { + if (!theme.showAvatar && avatarDrawerAnimation.isDismissed) { return; } final Color disabledColor = _disabledColor; diff --git a/packages/flutter/lib/src/material/selectable_text.dart b/packages/flutter/lib/src/material/selectable_text.dart index 91fc1fc4d8..433de56181 100644 --- a/packages/flutter/lib/src/material/selectable_text.dart +++ b/packages/flutter/lib/src/material/selectable_text.dart @@ -607,7 +607,7 @@ class _SelectableTextState extends State implements TextSelectio assert(debugCheckHasMediaQuery(context)); assert(debugCheckHasDirectionality(context)); assert( - !(widget.style != null && widget.style!.inherit == false && + !(widget.style != null && !widget.style!.inherit && (widget.style!.fontSize == null || widget.style!.textBaseline == null)), 'inherit false style must supply fontSize and textBaseline', ); diff --git a/packages/flutter/lib/src/material/slider_theme.dart b/packages/flutter/lib/src/material/slider_theme.dart index efbf9da23f..492de070e7 100644 --- a/packages/flutter/lib/src/material/slider_theme.dart +++ b/packages/flutter/lib/src/material/slider_theme.dart @@ -2335,7 +2335,7 @@ class RoundSliderThumbShape extends SliderComponentShape { @override Size getPreferredSize(bool isEnabled, bool isDiscrete) { - return Size.fromRadius(isEnabled == true ? enabledThumbRadius : _disabledThumbRadius); + return Size.fromRadius(isEnabled ? enabledThumbRadius : _disabledThumbRadius); } @override @@ -2444,7 +2444,7 @@ class RoundRangeSliderThumbShape extends RangeSliderThumbShape { @override Size getPreferredSize(bool isEnabled, bool isDiscrete) { - return Size.fromRadius(isEnabled == true ? enabledThumbRadius : _disabledThumbRadius); + return Size.fromRadius(isEnabled ? enabledThumbRadius : _disabledThumbRadius); } @override diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart index ec4b56816b..2800258346 100644 --- a/packages/flutter/lib/src/material/text_field.dart +++ b/packages/flutter/lib/src/material/text_field.dart @@ -1234,7 +1234,7 @@ class _TextFieldState extends State with RestorationMixin implements assert(debugCheckHasMaterialLocalizations(context)); assert(debugCheckHasDirectionality(context)); assert( - !(widget.style != null && widget.style!.inherit == false && + !(widget.style != null && !widget.style!.inherit && (widget.style!.fontSize == null || widget.style!.textBaseline == null)), 'inherit false style must supply fontSize and textBaseline', ); diff --git a/packages/flutter/lib/src/painting/debug.dart b/packages/flutter/lib/src/painting/debug.dart index d158a0e021..660de14668 100644 --- a/packages/flutter/lib/src/painting/debug.dart +++ b/packages/flutter/lib/src/painting/debug.dart @@ -185,7 +185,7 @@ bool debugAssertAllPaintingVarsUnset(String reason, { bool debugDisableShadowsOv if (debugDisableShadows != debugDisableShadowsOverride || debugNetworkImageHttpClientProvider != null || debugOnPaintImage != null || - debugInvertOversizedImages == true || + debugInvertOversizedImages || debugImageOverheadAllowance != _imageOverheadAllowanceDefault) { throw FlutterError(reason); } diff --git a/packages/flutter/lib/src/painting/inline_span.dart b/packages/flutter/lib/src/painting/inline_span.dart index 2a734dc326..8398549f71 100644 --- a/packages/flutter/lib/src/painting/inline_span.dart +++ b/packages/flutter/lib/src/painting/inline_span.dart @@ -60,7 +60,7 @@ class InlineSpanSemanticsInformation { this.semanticsLabel, this.stringAttributes = const [], this.recognizer, - }) : assert(isPlaceholder == false || (text == '\uFFFC' && semanticsLabel == null && recognizer == null)), + }) : assert(!isPlaceholder || (text == '\uFFFC' && semanticsLabel == null && recognizer == null)), requiresOwnNode = isPlaceholder || recognizer != null; /// The text info for a [PlaceholderSpan]. diff --git a/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart b/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart index 626b6dde63..546087eac6 100644 --- a/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart +++ b/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart @@ -151,7 +151,7 @@ class SliverMultiBoxAdaptorParentData extends SliverLogicalParentData with Conta bool _keptAlive = false; @override - String toString() => 'index=$index; ${keepAlive == true ? "keepAlive; " : ""}${super.toString()}'; + String toString() => 'index=$index; ${keepAlive ? "keepAlive; " : ""}${super.toString()}'; } /// A sliver with multiple box children. diff --git a/packages/flutter/lib/src/services/platform_views.dart b/packages/flutter/lib/src/services/platform_views.dart index f8ffe586b0..a024d6a764 100644 --- a/packages/flutter/lib/src/services/platform_views.dart +++ b/packages/flutter/lib/src/services/platform_views.dart @@ -1158,10 +1158,10 @@ abstract class _AndroidViewControllerInternals { 'id': viewId, 'viewType': viewType, 'direction': AndroidViewController._getAndroidDirection(layoutDirection), - if (hybrid == true) 'hybrid': hybrid, + if (hybrid) 'hybrid': hybrid, if (size != null) 'width': size.width, if (size != null) 'height': size.height, - if (hybridFallback == true) 'hybridFallback': hybridFallback, + if (hybridFallback) 'hybridFallback': hybridFallback, if (position != null) 'left': position.dx, if (position != null) 'top': position.dy, }; diff --git a/packages/flutter/lib/src/widgets/actions.dart b/packages/flutter/lib/src/widgets/actions.dart index ab746a0e6c..ce4183d6a7 100644 --- a/packages/flutter/lib/src/widgets/actions.dart +++ b/packages/flutter/lib/src/widgets/actions.dart @@ -690,7 +690,7 @@ class Actions extends StatefulWidget { static bool _visitActionsAncestors(BuildContext context, bool Function(InheritedElement element) visitor) { InheritedElement? actionsElement = context.getElementForInheritedWidgetOfExactType<_ActionsScope>(); while (actionsElement != null) { - if (visitor(actionsElement) == true) { + if (visitor(actionsElement)) { break; } // _getParent is needed here because diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index 824d00d0e1..7cd4ead6ef 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -1499,7 +1499,7 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute? scope = _scopeKey.currentState; assert(scope != null); for (final WillPopCallback callback in List.of(_willPopCallbacks)) { - if (await callback() != true) { + if (!await callback()) { return RoutePopDisposition.doNotPop; } } diff --git a/packages/flutter/lib/src/widgets/visibility.dart b/packages/flutter/lib/src/widgets/visibility.dart index 1c33c38b4f..eaf95eb2e3 100644 --- a/packages/flutter/lib/src/widgets/visibility.dart +++ b/packages/flutter/lib/src/widgets/visibility.dart @@ -64,19 +64,19 @@ class Visibility extends StatelessWidget { this.maintainSemantics = false, this.maintainInteractivity = false, }) : assert( - maintainState == true || maintainAnimation == false, + maintainState || !maintainAnimation, 'Cannot maintain animations if the state is not also maintained.', ), assert( - maintainAnimation == true || maintainSize == false, + maintainAnimation || !maintainSize, 'Cannot maintain size if animations are not maintained.', ), assert( - maintainSize == true || maintainSemantics == false, + maintainSize || !maintainSemantics, 'Cannot maintain semantics if size is not maintained.', ), assert( - maintainSize == true || maintainInteractivity == false, + maintainSize || !maintainInteractivity, 'Cannot maintain interactivity if size is not maintained.', ); @@ -354,19 +354,19 @@ class SliverVisibility extends StatelessWidget { this.maintainSemantics = false, this.maintainInteractivity = false, }) : assert( - maintainState == true || maintainAnimation == false, + maintainState || !maintainAnimation, 'Cannot maintain animations if the state is not also maintained.', ), assert( - maintainAnimation == true || maintainSize == false, + maintainAnimation || !maintainSize, 'Cannot maintain size if animations are not maintained.', ), assert( - maintainSize == true || maintainSemantics == false, + maintainSize || !maintainSemantics, 'Cannot maintain semantics if size is not maintained.', ), assert( - maintainSize == true || maintainInteractivity == false, + maintainSize || !maintainInteractivity, 'Cannot maintain interactivity if size is not maintained.', ); diff --git a/packages/flutter/lib/src/widgets/widget_inspector.dart b/packages/flutter/lib/src/widgets/widget_inspector.dart index 28d807d62c..b08712e2b7 100644 --- a/packages/flutter/lib/src/widgets/widget_inspector.dart +++ b/packages/flutter/lib/src/widgets/widget_inspector.dart @@ -3010,7 +3010,7 @@ class _InspectorOverlayLayer extends Layer { inDebugMode = true; return true; }()); - if (inDebugMode == false) { + if (!inDebugMode) { throw FlutterError.fromParts([ ErrorSummary( 'The inspector should never be used in production mode due to the ' @@ -3627,7 +3627,7 @@ class InspectorSerializationDelegate implements DiagnosticsSerializationDelegate @override List truncateNodesList(List nodes, DiagnosticsNode? owner) { if (maxDescendantsTruncatableNode >= 0 && - owner!.allowTruncate == true && + owner!.allowTruncate && nodes.length > maxDescendantsTruncatableNode) { nodes = service._truncateNodes(nodes, maxDescendantsTruncatableNode); } diff --git a/packages/flutter/test/widgets/image_test.dart b/packages/flutter/test/widgets/image_test.dart index 232a45bd71..ba06c7b421 100644 --- a/packages/flutter/test/widgets/image_test.dart +++ b/packages/flutter/test/widgets/image_test.dart @@ -2182,7 +2182,7 @@ class _FailingImageProvider extends ImageProvider { this.failOnLoad = false, required this.throws, required this.image, - }) : assert(failOnLoad == true || failOnObtainKey == true); + }) : assert(failOnLoad || failOnObtainKey); final bool failOnObtainKey; final bool failOnLoad; diff --git a/packages/flutter_test/lib/src/widget_tester.dart b/packages/flutter_test/lib/src/widget_tester.dart index 2b99e5fcaa..6e6d7ab132 100644 --- a/packages/flutter_test/lib/src/widget_tester.dart +++ b/packages/flutter_test/lib/src/widget_tester.dart @@ -149,7 +149,7 @@ void testWidgets( tester._testDescription = combinedDescription; SemanticsHandle? semanticsHandle; tester._recordNumberOfSemanticsHandles(); - if (semanticsEnabled == true) { + if (semanticsEnabled) { semanticsHandle = tester.ensureSemantics(); } test_package.addTearDown(binding.postTest); @@ -420,7 +420,7 @@ Future benchmarkWidgets( assert(binding is! AutomatedTestWidgetsFlutterBinding); final WidgetTester tester = WidgetTester._(binding); SemanticsHandle? semanticsHandle; - if (semanticsEnabled == true) { + if (semanticsEnabled) { semanticsHandle = tester.ensureSemantics(); } tester._recordNumberOfSemanticsHandles(); diff --git a/packages/flutter_tools/lib/src/base/build.dart b/packages/flutter_tools/lib/src/base/build.dart index f166bdb46d..9dcafd4b34 100644 --- a/packages/flutter_tools/lib/src/base/build.dart +++ b/packages/flutter_tools/lib/src/base/build.dart @@ -328,7 +328,7 @@ class AOTSnapshotter { } } } else { - assert(stripAfterBuild == false); + assert(!stripAfterBuild); } return 0; diff --git a/packages/flutter_tools/lib/src/base/logger.dart b/packages/flutter_tools/lib/src/base/logger.dart index 0b4dec079b..f8bac32f28 100644 --- a/packages/flutter_tools/lib/src/base/logger.dart +++ b/packages/flutter_tools/lib/src/base/logger.dart @@ -1101,7 +1101,7 @@ class PrefixedErrorLogger extends DelegatingLogger { bool? wrap, }) { hadErrorOutput = true; - if (message.trim().isNotEmpty == true) { + if (message.trim().isNotEmpty) { message = 'ERROR: $message'; } super.printError( diff --git a/packages/flutter_tools/lib/src/commands/custom_devices.dart b/packages/flutter_tools/lib/src/commands/custom_devices.dart index 7fda27a634..dee0ee7745 100644 --- a/packages/flutter_tools/lib/src/commands/custom_devices.dart +++ b/packages/flutter_tools/lib/src/commands/custom_devices.dart @@ -537,7 +537,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase { String? description, bool defaultsTo = true, }) async { - final String defaultsToStr = defaultsTo == true ? '[Y/n]' : '[y/N]'; + final String defaultsToStr = defaultsTo ? '[Y/n]' : '[y/N]'; logger.printStatus('$description $defaultsToStr (empty for default)'); while (true) { final String input = await inputs.next; @@ -784,7 +784,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase { if (stringArg(_kJson) != null) { return runNonInteractively(); } - if (boolArg(_kSsh) == true) { + if (boolArg(_kSsh)) { return runInteractivelySsh(); } throw UnsupportedError('Unknown run mode'); diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index 0be3c958a6..8bb6539d0a 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -793,7 +793,7 @@ class DefaultResidentCompiler implements ResidentCompiler { '--platform', platformDill!, ], - if (unsafePackageSerialization == true) '--unsafe-package-serialization', + if (unsafePackageSerialization) '--unsafe-package-serialization', // See: https://github.com/flutter/flutter/issues/103994 '--verbosity=error', ...?extraFrontEndOptions, diff --git a/packages/flutter_tools/lib/src/custom_devices/custom_device.dart b/packages/flutter_tools/lib/src/custom_devices/custom_device.dart index 864c592bff..dfa32e4ad2 100644 --- a/packages/flutter_tools/lib/src/custom_devices/custom_device.dart +++ b/packages/flutter_tools/lib/src/custom_devices/custom_device.dart @@ -706,7 +706,7 @@ class CustomDevice extends Device { @override Future takeScreenshot(File outputFile) async { - if (supportsScreenshot == false) { + if (!supportsScreenshot) { throw UnsupportedError('Screenshotting is not supported for this device.'); } @@ -874,7 +874,7 @@ class CustomDevices extends PollingDeviceDiscovery { ); // remove all the devices we couldn't reach. - pingedDevices.removeWhere((_, bool value) => value == false); + pingedDevices.removeWhere((_, bool value) => !value); // return only the devices. return pingedDevices.keys.toList(); diff --git a/packages/flutter_tools/lib/src/desktop_device.dart b/packages/flutter_tools/lib/src/desktop_device.dart index c58d9b9295..02d7534a9f 100644 --- a/packages/flutter_tools/lib/src/desktop_device.dart +++ b/packages/flutter_tools/lib/src/desktop_device.dart @@ -149,7 +149,7 @@ abstract class DesktopDevice extends Device { unawaited(process.exitCode.then((_) => _runningProcesses.remove(process))); _deviceLogReader.initializeProcess(process); - if (debuggingOptions.buildInfo.isRelease == true) { + if (debuggingOptions.buildInfo.isRelease) { return LaunchResult.succeeded(); } final ProtocolDiscovery vmServiceDiscovery = ProtocolDiscovery.vmService(_deviceLogReader, diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart index 285f677516..80d0fbd3dc 100644 --- a/packages/flutter_tools/lib/src/device.dart +++ b/packages/flutter_tools/lib/src/device.dart @@ -283,7 +283,7 @@ abstract class DeviceManager { bool includeDevicesUnsupportedByProject = false, }) { FlutterProject? flutterProject; - if (includeDevicesUnsupportedByProject == false) { + if (!includeDevicesUnsupportedByProject) { flutterProject = FlutterProject.current(); } if (hasSpecifiedAllDevices) { @@ -312,7 +312,7 @@ abstract class DeviceManager { Device? getSingleEphemeralDevice(List devices){ if (!hasSpecifiedDeviceId) { try { - return devices.singleWhere((Device device) => device.ephemeral == true); + return devices.singleWhere((Device device) => device.ephemeral); } on StateError { return null; } diff --git a/packages/flutter_tools/lib/src/doctor.dart b/packages/flutter_tools/lib/src/doctor.dart index 5af7820977..5744df33d7 100644 --- a/packages/flutter_tools/lib/src/doctor.dart +++ b/packages/flutter_tools/lib/src/doctor.dart @@ -410,7 +410,7 @@ class Doctor { } for (final ValidationMessage message in result.messages) { - if (!message.isInformation || verbose == true) { + if (!message.isInformation || verbose) { int hangingIndent = 2; int indent = 4; final String indicator = showColor ? message.coloredIndicator : message.indicator; diff --git a/packages/flutter_tools/lib/src/emulator.dart b/packages/flutter_tools/lib/src/emulator.dart index c65520ed8d..bcfe2d091c 100644 --- a/packages/flutter_tools/lib/src/emulator.dart +++ b/packages/flutter_tools/lib/src/emulator.dart @@ -56,8 +56,8 @@ class EmulatorManager { emulator.id.toLowerCase() == searchText || emulator.name.toLowerCase() == searchText; bool startsWithEmulatorId(Emulator emulator) => - emulator.id.toLowerCase().startsWith(searchText) == true || - emulator.name.toLowerCase().startsWith(searchText) == true; + emulator.id.toLowerCase().startsWith(searchText) || + emulator.name.toLowerCase().startsWith(searchText); Emulator? exactMatch; for (final Emulator emulator in emulators) { diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart index b1af3c7649..379fcb5f22 100644 --- a/packages/flutter_tools/lib/src/ios/devices.dart +++ b/packages/flutter_tools/lib/src/ios/devices.dart @@ -607,7 +607,7 @@ class IOSDevice extends Device { // If the debugger is not attached, killing the ios-deploy process won't stop the app. final IOSDeployDebugger? deployDebugger = iosDeployDebugger; if (deployDebugger != null && deployDebugger.debuggerAttached) { - return deployDebugger.exit() == true; + return deployDebugger.exit(); } return false; } diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart index f67e7b089e..011454bc00 100644 --- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart +++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart @@ -201,9 +201,9 @@ class XcodeProjectInterpreter { if (buildContext.environmentType == EnvironmentType.simulator) ...['-sdk', 'iphonesimulator'], '-destination', - if (buildContext.isWatch == true && buildContext.environmentType == EnvironmentType.physical) + if (buildContext.isWatch && buildContext.environmentType == EnvironmentType.physical) 'generic/platform=watchOS' - else if (buildContext.isWatch == true) + else if (buildContext.isWatch) 'generic/platform=watchOS Simulator' else if (deviceId != null) 'id=$deviceId' diff --git a/packages/flutter_tools/lib/src/migrations/cmake_custom_command_migration.dart b/packages/flutter_tools/lib/src/migrations/cmake_custom_command_migration.dart index 8949a82e36..54ddcb5652 100644 --- a/packages/flutter_tools/lib/src/migrations/cmake_custom_command_migration.dart +++ b/packages/flutter_tools/lib/src/migrations/cmake_custom_command_migration.dart @@ -48,7 +48,7 @@ class CmakeCustomCommandMigration extends ProjectMigrator { for (final RegExpMatch match in matches) { final String? addCustomCommandOriginal = match.group(1); - if (addCustomCommandOriginal != null && addCustomCommandOriginal.contains('VERBATIM') == false) { + if (addCustomCommandOriginal != null && !addCustomCommandOriginal.contains('VERBATIM')) { final String addCustomCommandReplacement = '$addCustomCommandOriginal\n VERBATIM'; newProjectContents = newProjectContents.replaceAll(addCustomCommandOriginal, addCustomCommandReplacement); } diff --git a/packages/flutter_tools/lib/src/proxied_devices/devices.dart b/packages/flutter_tools/lib/src/proxied_devices/devices.dart index 8d9be59ab4..332b30b0e5 100644 --- a/packages/flutter_tools/lib/src/proxied_devices/devices.dart +++ b/packages/flutter_tools/lib/src/proxied_devices/devices.dart @@ -638,7 +638,7 @@ class ProxiedPortForwarder extends DevicePortForwarder { } Future _defaultCreateServerSocket(Logger logger, int? hostPort, bool? ipv6) async { - if (ipv6 == null || ipv6 == false) { + if (ipv6 == null || !ipv6) { try { return await ServerSocket.bind(InternetAddress.loopbackIPv4, hostPort ?? 0); } on SocketException { diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart index 7ec52fb2e8..94586ff0ff 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart @@ -1172,7 +1172,7 @@ abstract class FlutterCommand extends Command { } final bool treeShakeIcons = argParser.options.containsKey('tree-shake-icons') - && buildMode.isPrecompiled == true + && buildMode.isPrecompiled && boolArg('tree-shake-icons'); final String? bundleSkSLPath = argParser.options.containsKey(FlutterOptions.kBundleSkSLPathOption) diff --git a/packages/flutter_tools/lib/src/xcode_project.dart b/packages/flutter_tools/lib/src/xcode_project.dart index 4f6f12cdaf..0e658a410d 100644 --- a/packages/flutter_tools/lib/src/xcode_project.dart +++ b/packages/flutter_tools/lib/src/xcode_project.dart @@ -508,7 +508,7 @@ class IosProject extends XcodeBasedProject { // In newer versions of Xcode, the build settings of the watchOS companion // app's scheme should contain the key INFOPLIST_KEY_WKCompanionAppBundleIdentifier. final bool watchIdentifierFound = xcodeProjectInfoFile.readAsStringSync().contains('WKCompanionAppBundleIdentifier'); - if (watchIdentifierFound == false) { + if (!watchIdentifierFound) { return false; } diff --git a/packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart index 5405f95e72..ece77ecc4b 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/analyze_continuously_test.dart @@ -103,7 +103,7 @@ void main() { ); int errorCount = 0; - final Future onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first; + final Future onDone = server.onAnalyzing.where((bool analyzing) => !analyzing).first; server.onErrors.listen((FileAnalysisErrors errors) => errorCount += errors.errors.length); await server.start(); @@ -144,7 +144,7 @@ void main() { ); int errorCount = 0; - final Future onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first; + final Future onDone = server.onAnalyzing.where((bool analyzing) => !analyzing).first; server.onErrors.listen((FileAnalysisErrors errors) { errorCount += errors.errors.length; }); @@ -172,7 +172,7 @@ void main() { ); int errorCount = 0; - final Future onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first; + final Future onDone = server.onAnalyzing.where((bool analyzing) => !analyzing).first; server.onErrors.listen((FileAnalysisErrors errors) { errorCount += errors.errors.length; }); diff --git a/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart index 797f5afbdd..7ff6ac46a7 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/clean_test.dart @@ -224,7 +224,7 @@ void main() { FlutterProject setupProjectUnderTest(Directory currentDirectory, bool setupXcodeWorkspace) { // This needs to be run within testWithoutContext and not setUp since FlutterProject uses context. final FlutterProject projectUnderTest = FlutterProject.fromDirectory(currentDirectory); - if (setupXcodeWorkspace == true) { + if (setupXcodeWorkspace) { projectUnderTest.ios.hostAppRoot.childDirectory('Runner.xcworkspace').createSync(recursive: true); projectUnderTest.macos.hostAppRoot.childDirectory('Runner.xcworkspace').createSync(recursive: true); } diff --git a/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart index 2731d287ad..82491edf81 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/create_usage_test.dart @@ -39,7 +39,7 @@ class FakePub extends Fake implements Pub { PubOutputMode outputMode = PubOutputMode.all, }) async { project.directory.childFile('.packages').createSync(); - if (offline == true) { + if (offline) { calledGetOffline += 1; } else { calledOnline += 1; diff --git a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart index 2adb5c2353..2ffedf4927 100644 --- a/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart +++ b/packages/flutter_tools/test/commands.shard/hermetic/run_test.dart @@ -1278,10 +1278,10 @@ class FakeDevice extends Fake implements Device { bool ipv6 = false, String? userIdentifier, }) async { - if (startAppSuccess == false) { + if (!startAppSuccess) { return LaunchResult.failed(); } - if (startAppSuccess == true) { + if (startAppSuccess) { return LaunchResult.succeeded(); } final String dartFlags = debuggingOptions.dartFlags; diff --git a/packages/flutter_tools/test/general.shard/args_test.dart b/packages/flutter_tools/test/general.shard/args_test.dart index 6fe315e4b9..a6f207d784 100644 --- a/packages/flutter_tools/test/general.shard/args_test.dart +++ b/packages/flutter_tools/test/general.shard/args_test.dart @@ -124,7 +124,7 @@ void verifyCommand(Command runner) { final String firstDescriptionLine = runner.description.split('\n').first; expect(firstDescriptionLine, matches(_allowedTrailingPatterns), reason: "command ${runner.name}'s description does not end with the expected single period that a full sentence should end with"); - if (runner.hidden == false && runner.parent == null) { + if (!runner.hidden && runner.parent == null) { expect( runner.category, anyOf( diff --git a/packages/flutter_tools/test/general.shard/channel_test.dart b/packages/flutter_tools/test/general.shard/channel_test.dart index b0fd63d097..5187fa76a3 100644 --- a/packages/flutter_tools/test/general.shard/channel_test.dart +++ b/packages/flutter_tools/test/general.shard/channel_test.dart @@ -163,7 +163,7 @@ void main() { final Iterable rows = testLogger.statusText .split('\n') .map((String line) => line.trim()) - .where((String line) => line.isNotEmpty == true) + .where((String line) => line.isNotEmpty) .skip(1); // remove `Flutter channels:` line expect(rows, ['beta', 'stable', 'Currently not on an official channel.']); @@ -194,7 +194,7 @@ void main() { final Iterable rows = testLogger.statusText .split('\n') .map((String line) => line.trim()) - .where((String line) => line.isNotEmpty == true) + .where((String line) => line.isNotEmpty) .skip(1); // remove `Flutter channels:` line expect(rows, ['beta', 'stable', 'Currently not on an official channel.']);