Implementing control flow collections (#146601)
This pull request aims for improved readability, based on issue #146600. ```dart // before Set<Color> _distinctVisibleColors() { final Set<Color> distinctVisibleColors = <Color>{}; if (top.style != BorderStyle.none) { distinctVisibleColors.add(top.color); } if (right.style != BorderStyle.none) { distinctVisibleColors.add(right.color); } if (bottom.style != BorderStyle.none) { distinctVisibleColors.add(bottom.color); } if (left.style != BorderStyle.none) { distinctVisibleColors.add(left.color); } return distinctVisibleColors; } // after Set<Color> _distinctVisibleColors() { return <Color>{ if (top.style != BorderStyle.none) top.color, if (right.style != BorderStyle.none) right.color, if (bottom.style != BorderStyle.none) bottom.color, if (left.style != BorderStyle.none) left.color, }; } ``` Most of the repo should be covered in this PR (aside from `flutter_tools/`, since there was a lot going on in there).
This commit is contained in:
@@ -106,16 +106,10 @@ class Response {
|
||||
|
||||
/// Create a list of Strings from [_failureDetails].
|
||||
List<String> _failureDetailsAsString() {
|
||||
final List<String> list = <String>[];
|
||||
if (_failureDetails == null || _failureDetails.isEmpty) {
|
||||
return list;
|
||||
}
|
||||
|
||||
for (final Failure failure in _failureDetails) {
|
||||
list.add(failure.toJson());
|
||||
}
|
||||
|
||||
return list;
|
||||
return <String>[
|
||||
if (_failureDetails != null)
|
||||
for (final Failure failure in _failureDetails) failure.toJson(),
|
||||
];
|
||||
}
|
||||
|
||||
/// Creates a [Failure] list using a json response.
|
||||
|
||||
Reference in New Issue
Block a user