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:
@@ -205,18 +205,11 @@ Map<String, String> reverseMapOfListOfString(Map<String, List<String>> inMap, vo
|
||||
///
|
||||
/// Will modify the input map.
|
||||
Map<String, dynamic> removeEmptyValues(Map<String, dynamic> map) {
|
||||
return map..removeWhere((String key, dynamic value) {
|
||||
if (value == null) {
|
||||
return true;
|
||||
}
|
||||
if (value is Map<String, dynamic>) {
|
||||
final Map<String, dynamic> regularizedMap = removeEmptyValues(value);
|
||||
return regularizedMap.isEmpty;
|
||||
}
|
||||
if (value is Iterable<dynamic>) {
|
||||
return value.isEmpty;
|
||||
}
|
||||
return false;
|
||||
return map..removeWhere((String key, dynamic value) => switch (value) {
|
||||
null => true,
|
||||
Map<String, dynamic>() => removeEmptyValues(value).isEmpty,
|
||||
Iterable<dynamic>() => value.isEmpty,
|
||||
_ => false,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user