Enable literal_only_boolean_expressions (#133186)
Blocking issue (https://github.com/dart-lang/linter/issues/453) for this lint has been resolved.
diff --git a/analysis_options.yaml b/analysis_options.yaml
index a9d2963..4da1e9f 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -116,7 +116,7 @@
- library_prefixes
- library_private_types_in_public_api
# - lines_longer_than_80_chars # not required by flutter style
- # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter/issues/453
+ - literal_only_boolean_expressions
# - matching_super_parameters # blocked on https://github.com/dart-lang/language/issues/2509
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
diff --git a/packages/flutter/lib/src/material/calendar_date_picker.dart b/packages/flutter/lib/src/material/calendar_date_picker.dart
index 878439b..2a3e842 100644
--- a/packages/flutter/lib/src/material/calendar_date_picker.dart
+++ b/packages/flutter/lib/src/material/calendar_date_picker.dart
@@ -915,14 +915,11 @@
///
List<Widget> _dayHeaders(TextStyle? headerStyle, MaterialLocalizations localizations) {
final List<Widget> result = <Widget>[];
- for (int i = localizations.firstDayOfWeekIndex; true; i = (i + 1) % 7) {
+ for (int i = localizations.firstDayOfWeekIndex; result.length < DateTime.daysPerWeek; i = (i + 1) % DateTime.daysPerWeek) {
final String weekday = localizations.narrowWeekdays[i];
result.add(ExcludeSemantics(
child: Center(child: Text(weekday, style: headerStyle)),
));
- if (i == (localizations.firstDayOfWeekIndex - 1) % 7) {
- break;
- }
}
return result;
}
diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart
index d5d2e1d..ea58556 100644
--- a/packages/flutter/lib/src/material/date_picker.dart
+++ b/packages/flutter/lib/src/material/date_picker.dart
@@ -2093,14 +2093,11 @@
///
List<Widget> _getDayHeaders(TextStyle headerStyle, MaterialLocalizations localizations) {
final List<Widget> result = <Widget>[];
- for (int i = localizations.firstDayOfWeekIndex; true; i = (i + 1) % 7) {
+ for (int i = localizations.firstDayOfWeekIndex; result.length < DateTime.daysPerWeek; i = (i + 1) % DateTime.daysPerWeek) {
final String weekday = localizations.narrowWeekdays[i];
result.add(ExcludeSemantics(
child: Center(child: Text(weekday, style: headerStyle)),
));
- if (i == (localizations.firstDayOfWeekIndex - 1) % 7) {
- break;
- }
}
return result;
}
@@ -2512,13 +2509,9 @@
final double gridHeight = weeks * _monthItemRowHeight + (weeks - 1) * _monthItemSpaceBetweenRows;
final List<Widget> dayItems = <Widget>[];
- for (int i = 0; true; i += 1) {
- // 1-based day of month, e.g. 1-31 for January, and 1-29 for February on
- // a leap year.
- final int day = i - dayOffset + 1;
- if (day > daysInMonth) {
- break;
- }
+ // 1-based day of month, e.g. 1-31 for January, and 1-29 for February on
+ // a leap year.
+ for (int day = 0 - dayOffset + 1; day <= daysInMonth; day += 1) {
if (day < 1) {
dayItems.add(Container());
} else {
diff --git a/packages/flutter/lib/src/rendering/viewport.dart b/packages/flutter/lib/src/rendering/viewport.dart
index 44876d8..66560c8 100644
--- a/packages/flutter/lib/src/rendering/viewport.dart
+++ b/packages/flutter/lib/src/rendering/viewport.dart
@@ -1830,7 +1830,7 @@
double correction;
double effectiveExtent;
- do {
+ while (true) {
correction = _attemptLayout(mainAxisExtent, crossAxisExtent, offset.pixels);
if (correction != 0.0) {
offset.correctBy(correction);
@@ -1847,7 +1847,7 @@
break;
}
}
- } while (true);
+ }
switch (axis) {
case Axis.vertical:
size = constraints.constrainDimensions(crossAxisExtent, effectiveExtent);
diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart
index 737def1..d062cc6 100644
--- a/packages/flutter_tools/lib/src/runner/flutter_command.dart
+++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart
@@ -486,7 +486,7 @@
}
ddsEnabled = !boolArg('disable-dds');
// TODO(ianh): enable the following code once google3 is migrated away from --disable-dds (and add test to flutter_command_test.dart)
- if (false) { // ignore: dead_code
+ if (false) { // ignore: dead_code, literal_only_boolean_expressions
if (ddsEnabled) {
globals.printWarning('${globals.logger.terminal
.warningMark} The "--no-disable-dds" argument is deprecated and redundant, and should be omitted.');