removeNullsAndTrimmedEmpty method

  1. @useResult
List<String>? removeNullsAndTrimmedEmpty({
  1. bool trim = true,
})

Drops nulls, then applies ListStringExtensions.removeTrimmedEmpty.

Returns null (never []) when nothing remains after removing nulls and trimmed-empty entries. Does not mutate the receiver.

Example:

<String?>[null, '', 'abc'].removeNullsAndTrimmedEmpty(); // ['abc']
<String?>[null, ' ', null].removeNullsAndTrimmedEmpty(); // null

Audited: 2026-06-12 11:26 EDT

Implementation

@useResult
List<String>? removeNullsAndTrimmedEmpty({bool trim = true}) =>
    nonNulls.toList().removeTrimmedEmpty(trim: trim);