Unverified Commit 5e1ba701 authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

enable no_literal_bool_comparisons lint (#126647)

parent b45f9b36
...@@ -127,7 +127,7 @@ linter: ...@@ -127,7 +127,7 @@ linter:
- no_duplicate_case_values - no_duplicate_case_values
- no_leading_underscores_for_library_prefixes - no_leading_underscores_for_library_prefixes
- no_leading_underscores_for_local_identifiers - 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_logic_in_create_state
# - no_runtimeType_toString # ok in tests; we enable this only in packages/ # - no_runtimeType_toString # ok in tests; we enable this only in packages/
- non_constant_identifier_names - non_constant_identifier_names
......
...@@ -809,7 +809,7 @@ Future<void> _runFrameworkTests() async { ...@@ -809,7 +809,7 @@ Future<void> _runFrameworkTests() async {
final List<String> tests = Directory(path.join(flutterRoot, 'packages', 'flutter', 'test')) final List<String> tests = Directory(path.join(flutterRoot, 'packages', 'flutter', 'test'))
.listSync(followLinks: false) .listSync(followLinks: false)
.whereType<Directory>() .whereType<Directory>()
.where((Directory dir) => dir.path.endsWith('widgets') == false) .where((Directory dir) => !dir.path.endsWith('widgets'))
.map<String>((Directory dir) => path.join('test', path.basename(dir.path)) + path.separator) .map<String>((Directory dir) => path.join('test', path.basename(dir.path)) + path.separator)
.toList(); .toList();
printProgress('${green}Running packages/flutter tests$reset for $cyan${tests.join(", ")}$reset'); printProgress('${green}Running packages/flutter tests$reset for $cyan${tests.join(", ")}$reset');
......
...@@ -99,7 +99,7 @@ class CodesignCommand extends Command<void> { ...@@ -99,7 +99,7 @@ class CodesignCommand extends Command<void> {
); );
} }
if (argResults!['verify'] as bool != true) { if (!(argResults!['verify'] as bool)) {
throw ConductorException( throw ConductorException(
'Sorry, but codesigning is not implemented yet. Please pass the ' 'Sorry, but codesigning is not implemented yet. Please pass the '
'--$kVerify flag to verify signatures.', '--$kVerify flag to verify signatures.',
......
...@@ -128,7 +128,7 @@ class NextContext extends Context { ...@@ -128,7 +128,7 @@ class NextContext extends Context {
stdio.printStatus('These must be applied manually in the directory ' stdio.printStatus('These must be applied manually in the directory '
'${state.engine.checkoutPath} before proceeding.\n'); '${state.engine.checkoutPath} before proceeding.\n');
} }
if (autoAccept == false) { if (!autoAccept) {
final bool response = await prompt( final bool response = await prompt(
'Are you ready to push your engine branch to the repository ' 'Are you ready to push your engine branch to the repository '
'${state.engine.mirror.url}?', '${state.engine.mirror.url}?',
...@@ -146,7 +146,7 @@ class NextContext extends Context { ...@@ -146,7 +146,7 @@ class NextContext extends Context {
'You must validate pre-submit CI for your engine PR, merge it, and codesign', 'You must validate pre-submit CI for your engine PR, merge it, and codesign',
'binaries before proceeding.\n', 'binaries before proceeding.\n',
].join('\n')); ].join('\n'));
if (autoAccept == false) { if (!autoAccept) {
// TODO(fujino): actually test if binaries have been codesigned on macOS // TODO(fujino): actually test if binaries have been codesigned on macOS
final bool response = await prompt( final bool response = await prompt(
'Has CI passed for the engine PR and binaries been codesigned?', 'Has CI passed for the engine PR and binaries been codesigned?',
...@@ -236,7 +236,7 @@ class NextContext extends Context { ...@@ -236,7 +236,7 @@ class NextContext extends Context {
); );
} }
if (autoAccept == false) { if (!autoAccept) {
final bool response = await prompt( final bool response = await prompt(
'Are you ready to push your framework branch to the repository ' 'Are you ready to push your framework branch to the repository '
'${state.framework.mirror.url}?', '${state.framework.mirror.url}?',
...@@ -276,7 +276,7 @@ class NextContext extends Context { ...@@ -276,7 +276,7 @@ class NextContext extends Context {
previousCheckoutLocation: state.engine.checkoutPath, previousCheckoutLocation: state.engine.checkoutPath,
); );
final String engineHead = await engine.reverseParse('HEAD'); final String engineHead = await engine.reverseParse('HEAD');
if (autoAccept == false) { if (!autoAccept) {
final bool response = await prompt( final bool response = await prompt(
'Are you ready to tag commit $frameworkHead as ${state.releaseVersion}\n' 'Are you ready to tag commit $frameworkHead as ${state.releaseVersion}\n'
'and push to remote ${state.framework.upstream.url}?', 'and push to remote ${state.framework.upstream.url}?',
...@@ -302,7 +302,7 @@ class NextContext extends Context { ...@@ -302,7 +302,7 @@ class NextContext extends Context {
previousCheckoutLocation: state.framework.checkoutPath, previousCheckoutLocation: state.framework.checkoutPath,
); );
final String headRevision = await framework.reverseParse('HEAD'); final String headRevision = await framework.reverseParse('HEAD');
if (autoAccept == false) { if (!autoAccept) {
// dryRun: true means print out git command // dryRun: true means print out git command
await framework.pushRef( await framework.pushRef(
fromRef: headRevision, fromRef: headRevision,
...@@ -332,7 +332,7 @@ class NextContext extends Context { ...@@ -332,7 +332,7 @@ class NextContext extends Context {
'The current status of packaging builds can be seen at:\n' 'The current status of packaging builds can be seen at:\n'
'\t$kLuciPackagingConsoleLink', '\t$kLuciPackagingConsoleLink',
); );
if (autoAccept == false) { if (!autoAccept) {
final bool response = await prompt( final bool response = await prompt(
'Have all packaging builds finished successfully and post release announcements been completed?'); 'Have all packaging builds finished successfully and post release announcements been completed?');
if (!response) { if (!response) {
...@@ -373,7 +373,7 @@ class NextContext extends Context { ...@@ -373,7 +373,7 @@ class NextContext extends Context {
force: force, force: force,
); );
} on GitException catch (exception) { } on GitException catch (exception) {
if (exception.type == GitExceptionType.PushRejected && force == false) { if (exception.type == GitExceptionType.PushRejected && !force) {
throw ConductorException( throw ConductorException(
'Push failed because the working branch named ' 'Push failed because the working branch named '
'${pbRepository.workingBranch} already exists on your mirror. ' '${pbRepository.workingBranch} already exists on your mirror. '
......
...@@ -176,7 +176,7 @@ Future<void> _runABTest({ ...@@ -176,7 +176,7 @@ Future<void> _runABTest({
abTest.addBResult(localEngineResult); abTest.addBResult(localEngineResult);
if (silent != true && i < runsPerTest) { if (!silent && i < runsPerTest) {
section('A/B results so far'); section('A/B results so far');
print(abTest.printSummary()); print(abTest.printSummary());
} }
...@@ -186,7 +186,7 @@ Future<void> _runABTest({ ...@@ -186,7 +186,7 @@ Future<void> _runABTest({
final File jsonFile = _uniqueFile(resultsFile); final File jsonFile = _uniqueFile(resultsFile);
jsonFile.writeAsStringSync(const JsonEncoder.withIndent(' ').convert(abTest.jsonMap)); jsonFile.writeAsStringSync(const JsonEncoder.withIndent(' ').convert(abTest.jsonMap));
if (silent != true) { if (!silent) {
section('Raw results'); section('Raw results');
print(abTest.rawResults()); print(abTest.rawResults());
} }
......
...@@ -602,7 +602,7 @@ class CupertinoSliverNavigationBar extends StatefulWidget { ...@@ -602,7 +602,7 @@ class CupertinoSliverNavigationBar extends StatefulWidget {
this.heroTag = _defaultHeroTag, this.heroTag = _defaultHeroTag,
this.stretch = false, this.stretch = false,
}) : assert( }) : assert(
automaticallyImplyTitle == true || largeTitle != null, automaticallyImplyTitle || largeTitle != null,
'No largeTitle has been provided but automaticallyImplyTitle is also ' 'No largeTitle has been provided but automaticallyImplyTitle is also '
'false. Either provide a largeTitle or set automaticallyImplyTitle to ' 'false. Either provide a largeTitle or set automaticallyImplyTitle to '
'true.', 'true.',
......
...@@ -1009,7 +1009,7 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti ...@@ -1009,7 +1009,7 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
isInDebugMode = true; isInDebugMode = true;
return 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) { if (!reportError && !forceReport) {
return; return;
} }
......
...@@ -1616,7 +1616,7 @@ abstract class DiagnosticsNode { ...@@ -1616,7 +1616,7 @@ abstract class DiagnosticsNode {
'showSeparator': showSeparator, 'showSeparator': showSeparator,
if (level != DiagnosticLevel.info) if (level != DiagnosticLevel.info)
'level': level.name, 'level': level.name,
if (showName == false) if (!showName)
'showName': showName, 'showName': showName,
if (emptyBodyDescription != null) if (emptyBodyDescription != null)
'emptyBodyDescription': emptyBodyDescription, 'emptyBodyDescription': emptyBodyDescription,
......
...@@ -205,9 +205,9 @@ int smallestButton(int buttons) => buttons & (-buttons); ...@@ -205,9 +205,9 @@ int smallestButton(int buttons) => buttons & (-buttons);
/// Example: /// Example:
/// ///
/// ```dart /// ```dart
/// assert(isSingleButton(0x1) == true); /// assert(isSingleButton(0x1));
/// assert(isSingleButton(0x11) == false); /// assert(!isSingleButton(0x11));
/// assert(isSingleButton(0) == false); /// assert(!isSingleButton(0));
/// ``` /// ```
/// ///
/// See also: /// See also:
......
...@@ -629,7 +629,7 @@ class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer { ...@@ -629,7 +629,7 @@ class LongPressGestureRecognizer extends PrimaryPointerGestureRecognizer {
} }
if (event is PointerUpEvent) { if (event is PointerUpEvent) {
if (_longPressAccepted == true) { if (_longPressAccepted) {
_checkLongPressEnd(event); _checkLongPressEnd(event);
} else { } else {
// Pointer is lifted before timeout. // Pointer is lifted before timeout.
......
...@@ -208,7 +208,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer { ...@@ -208,7 +208,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer {
// If second tap is not allowed, reset the state. // If second tap is not allowed, reset the state.
final bool isPointerAllowed = super.isPointerAllowed(event); final bool isPointerAllowed = super.isPointerAllowed(event);
if (isPointerAllowed == false) { if (!isPointerAllowed) {
_reset(); _reset();
} }
return isPointerAllowed; return isPointerAllowed;
......
...@@ -875,7 +875,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid ...@@ -875,7 +875,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid
setMaterialState(MaterialState.selected, widget.selected); setMaterialState(MaterialState.selected, widget.selected);
selectController = AnimationController( selectController = AnimationController(
duration: _kSelectDuration, duration: _kSelectDuration,
value: widget.selected == true ? 1.0 : 0.0, value: widget.selected ? 1.0 : 0.0,
vsync: this, vsync: this,
); );
selectionFade = CurvedAnimation( selectionFade = CurvedAnimation(
...@@ -884,7 +884,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid ...@@ -884,7 +884,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid
); );
avatarDrawerController = AnimationController( avatarDrawerController = AnimationController(
duration: _kDrawerDuration, duration: _kDrawerDuration,
value: hasAvatar || widget.selected == true ? 1.0 : 0.0, value: hasAvatar || widget.selected ? 1.0 : 0.0,
vsync: this, vsync: this,
); );
deleteDrawerController = AnimationController( deleteDrawerController = AnimationController(
...@@ -1042,7 +1042,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid ...@@ -1042,7 +1042,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid
} }
if (oldWidget.avatar != widget.avatar || oldWidget.selected != widget.selected) { if (oldWidget.avatar != widget.avatar || oldWidget.selected != widget.selected) {
setState(() { setState(() {
if (hasAvatar || widget.selected == true) { if (hasAvatar || widget.selected) {
avatarDrawerController.forward(); avatarDrawerController.forward();
} else { } else {
avatarDrawerController.reverse(); avatarDrawerController.reverse();
...@@ -1052,7 +1052,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid ...@@ -1052,7 +1052,7 @@ class _RawChipState extends State<RawChip> with MaterialStateMixin, TickerProvid
if (oldWidget.selected != widget.selected) { if (oldWidget.selected != widget.selected) {
setState(() { setState(() {
setMaterialState(MaterialState.selected, widget.selected); setMaterialState(MaterialState.selected, widget.selected);
if (widget.selected == true) { if (widget.selected) {
selectController.forward(); selectController.forward();
} else { } else {
selectController.reverse(); selectController.reverse();
...@@ -1979,7 +1979,7 @@ class _RenderChip extends RenderBox with SlottedContainerRenderObjectMixin<_Chip ...@@ -1979,7 +1979,7 @@ class _RenderChip extends RenderBox with SlottedContainerRenderObjectMixin<_Chip
_paintSelectionOverlay(context, offset); _paintSelectionOverlay(context, offset);
} }
if (theme.showAvatar == false && avatarDrawerAnimation.isDismissed) { if (!theme.showAvatar && avatarDrawerAnimation.isDismissed) {
return; return;
} }
final Color disabledColor = _disabledColor; final Color disabledColor = _disabledColor;
......
...@@ -607,7 +607,7 @@ class _SelectableTextState extends State<SelectableText> implements TextSelectio ...@@ -607,7 +607,7 @@ class _SelectableTextState extends State<SelectableText> implements TextSelectio
assert(debugCheckHasMediaQuery(context)); assert(debugCheckHasMediaQuery(context));
assert(debugCheckHasDirectionality(context)); assert(debugCheckHasDirectionality(context));
assert( assert(
!(widget.style != null && widget.style!.inherit == false && !(widget.style != null && !widget.style!.inherit &&
(widget.style!.fontSize == null || widget.style!.textBaseline == null)), (widget.style!.fontSize == null || widget.style!.textBaseline == null)),
'inherit false style must supply fontSize and textBaseline', 'inherit false style must supply fontSize and textBaseline',
); );
......
...@@ -2335,7 +2335,7 @@ class RoundSliderThumbShape extends SliderComponentShape { ...@@ -2335,7 +2335,7 @@ class RoundSliderThumbShape extends SliderComponentShape {
@override @override
Size getPreferredSize(bool isEnabled, bool isDiscrete) { Size getPreferredSize(bool isEnabled, bool isDiscrete) {
return Size.fromRadius(isEnabled == true ? enabledThumbRadius : _disabledThumbRadius); return Size.fromRadius(isEnabled ? enabledThumbRadius : _disabledThumbRadius);
} }
@override @override
...@@ -2444,7 +2444,7 @@ class RoundRangeSliderThumbShape extends RangeSliderThumbShape { ...@@ -2444,7 +2444,7 @@ class RoundRangeSliderThumbShape extends RangeSliderThumbShape {
@override @override
Size getPreferredSize(bool isEnabled, bool isDiscrete) { Size getPreferredSize(bool isEnabled, bool isDiscrete) {
return Size.fromRadius(isEnabled == true ? enabledThumbRadius : _disabledThumbRadius); return Size.fromRadius(isEnabled ? enabledThumbRadius : _disabledThumbRadius);
} }
@override @override
......
...@@ -1234,7 +1234,7 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements ...@@ -1234,7 +1234,7 @@ class _TextFieldState extends State<TextField> with RestorationMixin implements
assert(debugCheckHasMaterialLocalizations(context)); assert(debugCheckHasMaterialLocalizations(context));
assert(debugCheckHasDirectionality(context)); assert(debugCheckHasDirectionality(context));
assert( assert(
!(widget.style != null && widget.style!.inherit == false && !(widget.style != null && !widget.style!.inherit &&
(widget.style!.fontSize == null || widget.style!.textBaseline == null)), (widget.style!.fontSize == null || widget.style!.textBaseline == null)),
'inherit false style must supply fontSize and textBaseline', 'inherit false style must supply fontSize and textBaseline',
); );
......
...@@ -185,7 +185,7 @@ bool debugAssertAllPaintingVarsUnset(String reason, { bool debugDisableShadowsOv ...@@ -185,7 +185,7 @@ bool debugAssertAllPaintingVarsUnset(String reason, { bool debugDisableShadowsOv
if (debugDisableShadows != debugDisableShadowsOverride || if (debugDisableShadows != debugDisableShadowsOverride ||
debugNetworkImageHttpClientProvider != null || debugNetworkImageHttpClientProvider != null ||
debugOnPaintImage != null || debugOnPaintImage != null ||
debugInvertOversizedImages == true || debugInvertOversizedImages ||
debugImageOverheadAllowance != _imageOverheadAllowanceDefault) { debugImageOverheadAllowance != _imageOverheadAllowanceDefault) {
throw FlutterError(reason); throw FlutterError(reason);
} }
......
...@@ -60,7 +60,7 @@ class InlineSpanSemanticsInformation { ...@@ -60,7 +60,7 @@ class InlineSpanSemanticsInformation {
this.semanticsLabel, this.semanticsLabel,
this.stringAttributes = const <ui.StringAttribute>[], this.stringAttributes = const <ui.StringAttribute>[],
this.recognizer, this.recognizer,
}) : assert(isPlaceholder == false || (text == '\uFFFC' && semanticsLabel == null && recognizer == null)), }) : assert(!isPlaceholder || (text == '\uFFFC' && semanticsLabel == null && recognizer == null)),
requiresOwnNode = isPlaceholder || recognizer != null; requiresOwnNode = isPlaceholder || recognizer != null;
/// The text info for a [PlaceholderSpan]. /// The text info for a [PlaceholderSpan].
......
...@@ -151,7 +151,7 @@ class SliverMultiBoxAdaptorParentData extends SliverLogicalParentData with Conta ...@@ -151,7 +151,7 @@ class SliverMultiBoxAdaptorParentData extends SliverLogicalParentData with Conta
bool _keptAlive = false; bool _keptAlive = false;
@override @override
String toString() => 'index=$index; ${keepAlive == true ? "keepAlive; " : ""}${super.toString()}'; String toString() => 'index=$index; ${keepAlive ? "keepAlive; " : ""}${super.toString()}';
} }
/// A sliver with multiple box children. /// A sliver with multiple box children.
......
...@@ -1158,10 +1158,10 @@ abstract class _AndroidViewControllerInternals { ...@@ -1158,10 +1158,10 @@ abstract class _AndroidViewControllerInternals {
'id': viewId, 'id': viewId,
'viewType': viewType, 'viewType': viewType,
'direction': AndroidViewController._getAndroidDirection(layoutDirection), 'direction': AndroidViewController._getAndroidDirection(layoutDirection),
if (hybrid == true) 'hybrid': hybrid, if (hybrid) 'hybrid': hybrid,
if (size != null) 'width': size.width, if (size != null) 'width': size.width,
if (size != null) 'height': size.height, if (size != null) 'height': size.height,
if (hybridFallback == true) 'hybridFallback': hybridFallback, if (hybridFallback) 'hybridFallback': hybridFallback,
if (position != null) 'left': position.dx, if (position != null) 'left': position.dx,
if (position != null) 'top': position.dy, if (position != null) 'top': position.dy,
}; };
......
...@@ -690,7 +690,7 @@ class Actions extends StatefulWidget { ...@@ -690,7 +690,7 @@ class Actions extends StatefulWidget {
static bool _visitActionsAncestors(BuildContext context, bool Function(InheritedElement element) visitor) { static bool _visitActionsAncestors(BuildContext context, bool Function(InheritedElement element) visitor) {
InheritedElement? actionsElement = context.getElementForInheritedWidgetOfExactType<_ActionsScope>(); InheritedElement? actionsElement = context.getElementForInheritedWidgetOfExactType<_ActionsScope>();
while (actionsElement != null) { while (actionsElement != null) {
if (visitor(actionsElement) == true) { if (visitor(actionsElement)) {
break; break;
} }
// _getParent is needed here because // _getParent is needed here because
......
...@@ -1499,7 +1499,7 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T ...@@ -1499,7 +1499,7 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
final _ModalScopeState<T>? scope = _scopeKey.currentState; final _ModalScopeState<T>? scope = _scopeKey.currentState;
assert(scope != null); assert(scope != null);
for (final WillPopCallback callback in List<WillPopCallback>.of(_willPopCallbacks)) { for (final WillPopCallback callback in List<WillPopCallback>.of(_willPopCallbacks)) {
if (await callback() != true) { if (!await callback()) {
return RoutePopDisposition.doNotPop; return RoutePopDisposition.doNotPop;
} }
} }
......
...@@ -64,19 +64,19 @@ class Visibility extends StatelessWidget { ...@@ -64,19 +64,19 @@ class Visibility extends StatelessWidget {
this.maintainSemantics = false, this.maintainSemantics = false,
this.maintainInteractivity = false, this.maintainInteractivity = false,
}) : assert( }) : assert(
maintainState == true || maintainAnimation == false, maintainState || !maintainAnimation,
'Cannot maintain animations if the state is not also maintained.', 'Cannot maintain animations if the state is not also maintained.',
), ),
assert( assert(
maintainAnimation == true || maintainSize == false, maintainAnimation || !maintainSize,
'Cannot maintain size if animations are not maintained.', 'Cannot maintain size if animations are not maintained.',
), ),
assert( assert(
maintainSize == true || maintainSemantics == false, maintainSize || !maintainSemantics,
'Cannot maintain semantics if size is not maintained.', 'Cannot maintain semantics if size is not maintained.',
), ),
assert( assert(
maintainSize == true || maintainInteractivity == false, maintainSize || !maintainInteractivity,
'Cannot maintain interactivity if size is not maintained.', 'Cannot maintain interactivity if size is not maintained.',
); );
...@@ -354,19 +354,19 @@ class SliverVisibility extends StatelessWidget { ...@@ -354,19 +354,19 @@ class SliverVisibility extends StatelessWidget {
this.maintainSemantics = false, this.maintainSemantics = false,
this.maintainInteractivity = false, this.maintainInteractivity = false,
}) : assert( }) : assert(
maintainState == true || maintainAnimation == false, maintainState || !maintainAnimation,
'Cannot maintain animations if the state is not also maintained.', 'Cannot maintain animations if the state is not also maintained.',
), ),
assert( assert(
maintainAnimation == true || maintainSize == false, maintainAnimation || !maintainSize,
'Cannot maintain size if animations are not maintained.', 'Cannot maintain size if animations are not maintained.',
), ),
assert( assert(
maintainSize == true || maintainSemantics == false, maintainSize || !maintainSemantics,
'Cannot maintain semantics if size is not maintained.', 'Cannot maintain semantics if size is not maintained.',
), ),
assert( assert(
maintainSize == true || maintainInteractivity == false, maintainSize || !maintainInteractivity,
'Cannot maintain interactivity if size is not maintained.', 'Cannot maintain interactivity if size is not maintained.',
); );
......
...@@ -3010,7 +3010,7 @@ class _InspectorOverlayLayer extends Layer { ...@@ -3010,7 +3010,7 @@ class _InspectorOverlayLayer extends Layer {
inDebugMode = true; inDebugMode = true;
return true; return true;
}()); }());
if (inDebugMode == false) { if (!inDebugMode) {
throw FlutterError.fromParts(<DiagnosticsNode>[ throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary( ErrorSummary(
'The inspector should never be used in production mode due to the ' 'The inspector should never be used in production mode due to the '
...@@ -3627,7 +3627,7 @@ class InspectorSerializationDelegate implements DiagnosticsSerializationDelegate ...@@ -3627,7 +3627,7 @@ class InspectorSerializationDelegate implements DiagnosticsSerializationDelegate
@override @override
List<DiagnosticsNode> truncateNodesList(List<DiagnosticsNode> nodes, DiagnosticsNode? owner) { List<DiagnosticsNode> truncateNodesList(List<DiagnosticsNode> nodes, DiagnosticsNode? owner) {
if (maxDescendantsTruncatableNode >= 0 && if (maxDescendantsTruncatableNode >= 0 &&
owner!.allowTruncate == true && owner!.allowTruncate &&
nodes.length > maxDescendantsTruncatableNode) { nodes.length > maxDescendantsTruncatableNode) {
nodes = service._truncateNodes(nodes, maxDescendantsTruncatableNode); nodes = service._truncateNodes(nodes, maxDescendantsTruncatableNode);
} }
......
...@@ -2182,7 +2182,7 @@ class _FailingImageProvider extends ImageProvider<int> { ...@@ -2182,7 +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 == true || failOnObtainKey == true); }) : assert(failOnLoad || failOnObtainKey);
final bool failOnObtainKey; final bool failOnObtainKey;
final bool failOnLoad; final bool failOnLoad;
......
...@@ -149,7 +149,7 @@ void testWidgets( ...@@ -149,7 +149,7 @@ void testWidgets(
tester._testDescription = combinedDescription; tester._testDescription = combinedDescription;
SemanticsHandle? semanticsHandle; SemanticsHandle? semanticsHandle;
tester._recordNumberOfSemanticsHandles(); tester._recordNumberOfSemanticsHandles();
if (semanticsEnabled == true) { if (semanticsEnabled) {
semanticsHandle = tester.ensureSemantics(); semanticsHandle = tester.ensureSemantics();
} }
test_package.addTearDown(binding.postTest); test_package.addTearDown(binding.postTest);
...@@ -420,7 +420,7 @@ Future<void> benchmarkWidgets( ...@@ -420,7 +420,7 @@ Future<void> benchmarkWidgets(
assert(binding is! AutomatedTestWidgetsFlutterBinding); assert(binding is! AutomatedTestWidgetsFlutterBinding);
final WidgetTester tester = WidgetTester._(binding); final WidgetTester tester = WidgetTester._(binding);
SemanticsHandle? semanticsHandle; SemanticsHandle? semanticsHandle;
if (semanticsEnabled == true) { if (semanticsEnabled) {
semanticsHandle = tester.ensureSemantics(); semanticsHandle = tester.ensureSemantics();
} }
tester._recordNumberOfSemanticsHandles(); tester._recordNumberOfSemanticsHandles();
......
...@@ -328,7 +328,7 @@ class AOTSnapshotter { ...@@ -328,7 +328,7 @@ class AOTSnapshotter {
} }
} }
} else { } else {
assert(stripAfterBuild == false); assert(!stripAfterBuild);
} }
return 0; return 0;
......
...@@ -1101,7 +1101,7 @@ class PrefixedErrorLogger extends DelegatingLogger { ...@@ -1101,7 +1101,7 @@ class PrefixedErrorLogger extends DelegatingLogger {
bool? wrap, bool? wrap,
}) { }) {
hadErrorOutput = true; hadErrorOutput = true;
if (message.trim().isNotEmpty == true) { if (message.trim().isNotEmpty) {
message = 'ERROR: $message'; message = 'ERROR: $message';
} }
super.printError( super.printError(
......
...@@ -537,7 +537,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase { ...@@ -537,7 +537,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
String? description, String? description,
bool defaultsTo = true, bool defaultsTo = true,
}) async { }) 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)'); logger.printStatus('$description $defaultsToStr (empty for default)');
while (true) { while (true) {
final String input = await inputs.next; final String input = await inputs.next;
...@@ -784,7 +784,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase { ...@@ -784,7 +784,7 @@ class CustomDevicesAddCommand extends CustomDevicesCommandBase {
if (stringArg(_kJson) != null) { if (stringArg(_kJson) != null) {
return runNonInteractively(); return runNonInteractively();
} }
if (boolArg(_kSsh) == true) { if (boolArg(_kSsh)) {
return runInteractivelySsh(); return runInteractivelySsh();
} }
throw UnsupportedError('Unknown run mode'); throw UnsupportedError('Unknown run mode');
......
...@@ -793,7 +793,7 @@ class DefaultResidentCompiler implements ResidentCompiler { ...@@ -793,7 +793,7 @@ class DefaultResidentCompiler implements ResidentCompiler {
'--platform', '--platform',
platformDill!, platformDill!,
], ],
if (unsafePackageSerialization == true) '--unsafe-package-serialization', if (unsafePackageSerialization) '--unsafe-package-serialization',
// See: https://github.com/flutter/flutter/issues/103994 // See: https://github.com/flutter/flutter/issues/103994
'--verbosity=error', '--verbosity=error',
...?extraFrontEndOptions, ...?extraFrontEndOptions,
......
...@@ -706,7 +706,7 @@ class CustomDevice extends Device { ...@@ -706,7 +706,7 @@ class CustomDevice extends Device {
@override @override
Future<void> takeScreenshot(File outputFile) async { Future<void> takeScreenshot(File outputFile) async {
if (supportsScreenshot == false) { if (!supportsScreenshot) {
throw UnsupportedError('Screenshotting is not supported for this device.'); throw UnsupportedError('Screenshotting is not supported for this device.');
} }
...@@ -874,7 +874,7 @@ class CustomDevices extends PollingDeviceDiscovery { ...@@ -874,7 +874,7 @@ class CustomDevices extends PollingDeviceDiscovery {
); );
// remove all the devices we couldn't reach. // remove all the devices we couldn't reach.
pingedDevices.removeWhere((_, bool value) => value == false); pingedDevices.removeWhere((_, bool value) => !value);
// return only the devices. // return only the devices.
return pingedDevices.keys.toList(); return pingedDevices.keys.toList();
......
...@@ -149,7 +149,7 @@ abstract class DesktopDevice extends Device { ...@@ -149,7 +149,7 @@ abstract class DesktopDevice extends Device {
unawaited(process.exitCode.then((_) => _runningProcesses.remove(process))); unawaited(process.exitCode.then((_) => _runningProcesses.remove(process)));
_deviceLogReader.initializeProcess(process); _deviceLogReader.initializeProcess(process);
if (debuggingOptions.buildInfo.isRelease == true) { if (debuggingOptions.buildInfo.isRelease) {
return LaunchResult.succeeded(); return LaunchResult.succeeded();
} }
final ProtocolDiscovery vmServiceDiscovery = ProtocolDiscovery.vmService(_deviceLogReader, final ProtocolDiscovery vmServiceDiscovery = ProtocolDiscovery.vmService(_deviceLogReader,
......
...@@ -283,7 +283,7 @@ abstract class DeviceManager { ...@@ -283,7 +283,7 @@ abstract class DeviceManager {
bool includeDevicesUnsupportedByProject = false, bool includeDevicesUnsupportedByProject = false,
}) { }) {
FlutterProject? flutterProject; FlutterProject? flutterProject;
if (includeDevicesUnsupportedByProject == false) { if (!includeDevicesUnsupportedByProject) {
flutterProject = FlutterProject.current(); flutterProject = FlutterProject.current();
} }
if (hasSpecifiedAllDevices) { if (hasSpecifiedAllDevices) {
...@@ -312,7 +312,7 @@ abstract class DeviceManager { ...@@ -312,7 +312,7 @@ abstract class DeviceManager {
Device? getSingleEphemeralDevice(List<Device> devices){ Device? getSingleEphemeralDevice(List<Device> devices){
if (!hasSpecifiedDeviceId) { if (!hasSpecifiedDeviceId) {
try { try {
return devices.singleWhere((Device device) => device.ephemeral == true); return devices.singleWhere((Device device) => device.ephemeral);
} on StateError { } on StateError {
return null; return null;
} }
......
...@@ -410,7 +410,7 @@ class Doctor { ...@@ -410,7 +410,7 @@ class Doctor {
} }
for (final ValidationMessage message in result.messages) { for (final ValidationMessage message in result.messages) {
if (!message.isInformation || verbose == true) { if (!message.isInformation || verbose) {
int hangingIndent = 2; int hangingIndent = 2;
int indent = 4; int indent = 4;
final String indicator = showColor ? message.coloredIndicator : message.indicator; final String indicator = showColor ? message.coloredIndicator : message.indicator;
......
...@@ -56,8 +56,8 @@ class EmulatorManager { ...@@ -56,8 +56,8 @@ class EmulatorManager {
emulator.id.toLowerCase() == searchText || emulator.id.toLowerCase() == searchText ||
emulator.name.toLowerCase() == searchText; emulator.name.toLowerCase() == searchText;
bool startsWithEmulatorId(Emulator emulator) => bool startsWithEmulatorId(Emulator emulator) =>
emulator.id.toLowerCase().startsWith(searchText) == true || emulator.id.toLowerCase().startsWith(searchText) ||
emulator.name.toLowerCase().startsWith(searchText) == true; emulator.name.toLowerCase().startsWith(searchText);
Emulator? exactMatch; Emulator? exactMatch;
for (final Emulator emulator in emulators) { for (final Emulator emulator in emulators) {
......
...@@ -607,7 +607,7 @@ class IOSDevice extends Device { ...@@ -607,7 +607,7 @@ class IOSDevice extends Device {
// If the debugger is not attached, killing the ios-deploy process won't stop the app. // If the debugger is not attached, killing the ios-deploy process won't stop the app.
final IOSDeployDebugger? deployDebugger = iosDeployDebugger; final IOSDeployDebugger? deployDebugger = iosDeployDebugger;
if (deployDebugger != null && deployDebugger.debuggerAttached) { if (deployDebugger != null && deployDebugger.debuggerAttached) {
return deployDebugger.exit() == true; return deployDebugger.exit();
} }
return false; return false;
} }
......
...@@ -201,9 +201,9 @@ class XcodeProjectInterpreter { ...@@ -201,9 +201,9 @@ class XcodeProjectInterpreter {
if (buildContext.environmentType == EnvironmentType.simulator) if (buildContext.environmentType == EnvironmentType.simulator)
...<String>['-sdk', 'iphonesimulator'], ...<String>['-sdk', 'iphonesimulator'],
'-destination', '-destination',
if (buildContext.isWatch == true && buildContext.environmentType == EnvironmentType.physical) if (buildContext.isWatch && buildContext.environmentType == EnvironmentType.physical)
'generic/platform=watchOS' 'generic/platform=watchOS'
else if (buildContext.isWatch == true) else if (buildContext.isWatch)
'generic/platform=watchOS Simulator' 'generic/platform=watchOS Simulator'
else if (deviceId != null) else if (deviceId != null)
'id=$deviceId' 'id=$deviceId'
......
...@@ -48,7 +48,7 @@ class CmakeCustomCommandMigration extends ProjectMigrator { ...@@ -48,7 +48,7 @@ class CmakeCustomCommandMigration extends ProjectMigrator {
for (final RegExpMatch match in matches) { for (final RegExpMatch match in matches) {
final String? addCustomCommandOriginal = match.group(1); 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'; final String addCustomCommandReplacement = '$addCustomCommandOriginal\n VERBATIM';
newProjectContents = newProjectContents.replaceAll(addCustomCommandOriginal, addCustomCommandReplacement); newProjectContents = newProjectContents.replaceAll(addCustomCommandOriginal, addCustomCommandReplacement);
} }
......
...@@ -638,7 +638,7 @@ class ProxiedPortForwarder extends DevicePortForwarder { ...@@ -638,7 +638,7 @@ class ProxiedPortForwarder extends DevicePortForwarder {
} }
Future<ServerSocket> _defaultCreateServerSocket(Logger logger, int? hostPort, bool? ipv6) async { Future<ServerSocket> _defaultCreateServerSocket(Logger logger, int? hostPort, bool? ipv6) async {
if (ipv6 == null || ipv6 == false) { if (ipv6 == null || !ipv6) {
try { try {
return await ServerSocket.bind(InternetAddress.loopbackIPv4, hostPort ?? 0); return await ServerSocket.bind(InternetAddress.loopbackIPv4, hostPort ?? 0);
} on SocketException { } on SocketException {
......
...@@ -1172,7 +1172,7 @@ abstract class FlutterCommand extends Command<void> { ...@@ -1172,7 +1172,7 @@ abstract class FlutterCommand extends Command<void> {
} }
final bool treeShakeIcons = argParser.options.containsKey('tree-shake-icons') final bool treeShakeIcons = argParser.options.containsKey('tree-shake-icons')
&& buildMode.isPrecompiled == true && buildMode.isPrecompiled
&& boolArg('tree-shake-icons'); && boolArg('tree-shake-icons');
final String? bundleSkSLPath = argParser.options.containsKey(FlutterOptions.kBundleSkSLPathOption) final String? bundleSkSLPath = argParser.options.containsKey(FlutterOptions.kBundleSkSLPathOption)
......
...@@ -508,7 +508,7 @@ class IosProject extends XcodeBasedProject { ...@@ -508,7 +508,7 @@ class IosProject extends XcodeBasedProject {
// In newer versions of Xcode, the build settings of the watchOS companion // In newer versions of Xcode, the build settings of the watchOS companion
// app's scheme should contain the key INFOPLIST_KEY_WKCompanionAppBundleIdentifier. // app's scheme should contain the key INFOPLIST_KEY_WKCompanionAppBundleIdentifier.
final bool watchIdentifierFound = xcodeProjectInfoFile.readAsStringSync().contains('WKCompanionAppBundleIdentifier'); final bool watchIdentifierFound = xcodeProjectInfoFile.readAsStringSync().contains('WKCompanionAppBundleIdentifier');
if (watchIdentifierFound == false) { if (!watchIdentifierFound) {
return false; return false;
} }
......
...@@ -103,7 +103,7 @@ void main() { ...@@ -103,7 +103,7 @@ void main() {
); );
int errorCount = 0; int errorCount = 0;
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first; final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => !analyzing).first;
server.onErrors.listen((FileAnalysisErrors errors) => errorCount += errors.errors.length); server.onErrors.listen((FileAnalysisErrors errors) => errorCount += errors.errors.length);
await server.start(); await server.start();
...@@ -144,7 +144,7 @@ void main() { ...@@ -144,7 +144,7 @@ void main() {
); );
int errorCount = 0; int errorCount = 0;
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first; final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => !analyzing).first;
server.onErrors.listen((FileAnalysisErrors errors) { server.onErrors.listen((FileAnalysisErrors errors) {
errorCount += errors.errors.length; errorCount += errors.errors.length;
}); });
...@@ -172,7 +172,7 @@ void main() { ...@@ -172,7 +172,7 @@ void main() {
); );
int errorCount = 0; int errorCount = 0;
final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first; final Future<bool> onDone = server.onAnalyzing.where((bool analyzing) => !analyzing).first;
server.onErrors.listen((FileAnalysisErrors errors) { server.onErrors.listen((FileAnalysisErrors errors) {
errorCount += errors.errors.length; errorCount += errors.errors.length;
}); });
......
...@@ -224,7 +224,7 @@ void main() { ...@@ -224,7 +224,7 @@ void main() {
FlutterProject setupProjectUnderTest(Directory currentDirectory, bool setupXcodeWorkspace) { FlutterProject setupProjectUnderTest(Directory currentDirectory, bool setupXcodeWorkspace) {
// This needs to be run within testWithoutContext and not setUp since FlutterProject uses context. // This needs to be run within testWithoutContext and not setUp since FlutterProject uses context.
final FlutterProject projectUnderTest = FlutterProject.fromDirectory(currentDirectory); final FlutterProject projectUnderTest = FlutterProject.fromDirectory(currentDirectory);
if (setupXcodeWorkspace == true) { if (setupXcodeWorkspace) {
projectUnderTest.ios.hostAppRoot.childDirectory('Runner.xcworkspace').createSync(recursive: true); projectUnderTest.ios.hostAppRoot.childDirectory('Runner.xcworkspace').createSync(recursive: true);
projectUnderTest.macos.hostAppRoot.childDirectory('Runner.xcworkspace').createSync(recursive: true); projectUnderTest.macos.hostAppRoot.childDirectory('Runner.xcworkspace').createSync(recursive: true);
} }
......
...@@ -39,7 +39,7 @@ class FakePub extends Fake implements Pub { ...@@ -39,7 +39,7 @@ class FakePub extends Fake implements Pub {
PubOutputMode outputMode = PubOutputMode.all, PubOutputMode outputMode = PubOutputMode.all,
}) async { }) async {
project.directory.childFile('.packages').createSync(); project.directory.childFile('.packages').createSync();
if (offline == true) { if (offline) {
calledGetOffline += 1; calledGetOffline += 1;
} else { } else {
calledOnline += 1; calledOnline += 1;
......
...@@ -1278,10 +1278,10 @@ class FakeDevice extends Fake implements Device { ...@@ -1278,10 +1278,10 @@ class FakeDevice extends Fake implements Device {
bool ipv6 = false, bool ipv6 = false,
String? userIdentifier, String? userIdentifier,
}) async { }) async {
if (startAppSuccess == false) { if (!startAppSuccess) {
return LaunchResult.failed(); return LaunchResult.failed();
} }
if (startAppSuccess == true) { if (startAppSuccess) {
return LaunchResult.succeeded(); return LaunchResult.succeeded();
} }
final String dartFlags = debuggingOptions.dartFlags; final String dartFlags = debuggingOptions.dartFlags;
......
...@@ -124,7 +124,7 @@ void verifyCommand(Command<Object?> runner) { ...@@ -124,7 +124,7 @@ void verifyCommand(Command<Object?> runner) {
final String firstDescriptionLine = runner.description.split('\n').first; 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"); 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( expect(
runner.category, runner.category,
anyOf( anyOf(
......
...@@ -163,7 +163,7 @@ void main() { ...@@ -163,7 +163,7 @@ void main() {
final Iterable<String> rows = testLogger.statusText final Iterable<String> rows = testLogger.statusText
.split('\n') .split('\n')
.map((String line) => line.trim()) .map((String line) => line.trim())
.where((String line) => line.isNotEmpty == true) .where((String line) => line.isNotEmpty)
.skip(1); // remove `Flutter channels:` line .skip(1); // remove `Flutter channels:` line
expect(rows, <String>['beta', 'stable', 'Currently not on an official channel.']); expect(rows, <String>['beta', 'stable', 'Currently not on an official channel.']);
...@@ -194,7 +194,7 @@ void main() { ...@@ -194,7 +194,7 @@ void main() {
final Iterable<String> rows = testLogger.statusText final Iterable<String> rows = testLogger.statusText
.split('\n') .split('\n')
.map((String line) => line.trim()) .map((String line) => line.trim())
.where((String line) => line.isNotEmpty == true) .where((String line) => line.isNotEmpty)
.skip(1); // remove `Flutter channels:` line .skip(1); // remove `Flutter channels:` line
expect(rows, <String>['beta', 'stable', 'Currently not on an official channel.']); expect(rows, <String>['beta', 'stable', 'Currently not on an official channel.']);
......
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