words method

  1. @useResult
List<String>? words()

Returns this string split into a list of words, or null if empty.

Uses space as the delimiter and filters out empty words.

Implementation

@useResult
List<String>? words() {
  if (isEmpty) {
    return null;
  }

  return split(
    ' ',
  ).map((String word) => word.nullIfEmpty()).whereType<String>().toList().nullIfEmpty();
}