IterableModifier<E> extension

Extension providing null-safe utility methods for iterables.

Adds convenience methods to all Iterable types for common operations that may not find matching elements, returning null instead of throwing exceptions.

This extension is particularly useful when searching collections where the element may not exist, avoiding the need for try-catch blocks or pre-checking with any.

Example:

final depots = [depot1, depot2, depot3];
final depot = depots.firstWhereOrNull((d) => d.code == 'D001');
if (depot != null) {
  // Use depot
} else {
  // Handle not found case
}
on

Methods

firstWhereOrNull(bool test(E)) → E?

Available on Iterable<E>, provided by the IterableModifier extension

The first element satisfying test, or null if none match.