Reland "if chains → switch expressions" (#148634)
I did a goof a while back:

Now that [the bug is fixed](e9d403541f), I think we're good to re-implement the if-chains cleanup!
Related:
- https://github.com/flutter/flutter/pull/147793
- https://github.com/flutter/flutter/pull/148556
- https://github.com/flutter/flutter/issues/148548
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user