Skip to content

Commit

Permalink
simplify example in prefer_if_elements_to_conditional_expressions (#3495
Browse files Browse the repository at this point in the history
)
  • Loading branch information
a14n committed Jul 11, 2022
1 parent b4afc10 commit fad3a76
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions lib/src/rules/prefer_if_elements_to_conditional_expressions.dart
Expand Up @@ -15,28 +15,12 @@ conditionals.
**BAD:**
```dart
Widget build(BuildContext context) {
return Row(
children: [
IconButton(icon: Icon(Icons.menu)),
Expanded(child: title),
isAndroid ? IconButton(icon: Icon(Icons.search)) : null,
].where((child) => child != null).toList(),
);
}
var list = ['a', 'b', condition ? 'c' : null].where((e) => e != null).toList();
```
**GOOD:**
```dart
Widget build(BuildContext context) {
return Row(
children: [
IconButton(icon: Icon(Icons.menu)),
Expanded(child: title),
if (isAndroid) IconButton(icon: Icon(Icons.search)),
]
);
}
var list = ['a', 'b', if (condition) 'c'];
```
''';

Expand Down

0 comments on commit fad3a76

Please sign in to comment.