prefer_is_not_empty

Group: style

Maturity: stable

Dart SDK: >= 2.0.0 • (Linter v0.1.5)

flutter pedantic

View the Project on GitHub dart-lang/linter

PREFER x.isNotEmpty to !x.isEmpty for Iterable and Map instances.

When testing whether an iterable or map is empty, prefer isNotEmpty over !isEmpty to improve code readability.

GOOD:

if (todo.isNotEmpty) {
  sendResults(request, todo.isEmpty);
}

BAD:

if (!sources.isEmpty) {
  process(sources);
}