if chains → switch expressions (#147793)

Previous "if-chains" pull requests:
- https://github.com/flutter/flutter/pull/144905
- https://github.com/flutter/flutter/pull/144977
- https://github.com/flutter/flutter/pull/145194
- https://github.com/flutter/flutter/pull/146293
- https://github.com/flutter/flutter/pull/147472

<br>

I think this one should be enough to wrap things up!

fixes https://github.com/flutter/flutter/issues/144903

---------

Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
This commit is contained in:
Nate
2024-05-10 00:55:48 -06:00
committed by GitHub
parent c90e18c6f5
commit 4734d80f22
33 changed files with 194 additions and 297 deletions

View File

@@ -209,13 +209,11 @@ class ListItem extends StatelessWidget {
}
String _convertCountToStr(int count) {
if (count < 10000) {
return count.toString();
} else if (count < 100000) {
return '${(count / 10000).toStringAsPrecision(2)}w';
} else {
return '${(count / 10000).floor()}w';
}
return switch (count) {
< 10000 => count.toString(),
< 100000 => '${(count / 10000).toStringAsPrecision(2)}w',
_ => '${(count / 10000).floor()}w',
};
}
Widget _buildUserInfo() {

View File

@@ -31,13 +31,11 @@ class BenchBuildMaterialCheckbox extends WidgetBuildRecorder {
}
Row _buildRow() {
if (_isChecked == null) {
_isChecked = true;
} else if (_isChecked!) {
_isChecked = false;
} else {
_isChecked = null;
}
_isChecked = switch (_isChecked) {
null => true,
true => false,
false => null,
};
return Row(
children: List<Widget>.generate(10, (int i) {