isNotEmpty property

bool get isNotEmpty

Check if list is not empty and not null

Returns true if list exists and contains elements. Safe to call on null lists.

Returns

  • true: List exists and contains elements
  • false: List is null or empty

Example

final List<int>? list = [1, 2, 3];
if (list.isNotEmpty) {
  process(list!);
}

Implementation

bool get isNotEmpty => this != null && this!.isNotEmpty;