Dart Analyze logoDart Analyze/
DRT-W1148

Use `isNotEmpty` for Iterables and MapsDRT-W1148

Major severityMajor
Anti-pattern categoryAnti-pattern

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.

BAD:

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

GOOD:

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