StringTextExtensions extension

Extensions on String for words, grammar, lines, and text display.

on

Methods

collapseMultilineString({required int cropLength, bool appendEllipsis = true}) String

Available on String, provided by the StringTextExtensions extension

Returns this multiline string collapsed into a single line, truncated to cropLength characters.
compressSpaces({bool trim = true}) String?

Available on String, provided by the StringTextExtensions extension

Returns the result of collapsing consecutive whitespace, or null if empty. Alias for removeConsecutiveSpaces. Audited: 2026-06-12 11:26 EDT
firstLines(int limit) String

Available on String, provided by the StringTextExtensions extension

Returns the first limit lines of this string. Audited: 2026-06-12 11:26 EDT
firstWord() String?

Available on String, provided by the StringTextExtensions extension

Returns the first word of this string, or null if empty. Audited: 2026-06-12 11:26 EDT
grammarArticle() String

Available on String, provided by the StringTextExtensions extension

Returns the appropriate indefinite article ('a' or 'an') for this word, or an empty string if input is empty.
multiLinePrefix(String insertText, {bool prefixEmptyStrings = false}) String

Available on String, provided by the StringTextExtensions extension

Returns a new string with insertText prepended to every line.
pluralize(num? count, {bool simple = false}) String

Available on String, provided by the StringTextExtensions extension

Returns the plural form of this string based on count.
possess({bool isLocaleUS = true}) String

Available on String, provided by the StringTextExtensions extension

Returns the possessive form of this string (e.g., "John's", "boss'").
removeConsecutiveSpaces({bool trim = true}) String?

Available on String, provided by the StringTextExtensions extension

Returns a new string with consecutive whitespace collapsed into a single space, or null if the result is empty.
removeSingleCharacterWords({bool trim = true, bool removeMultipleSpaces = true}) String?

Available on String, provided by the StringTextExtensions extension

Returns a new string with single-character words removed, or null if the result is empty.
secondWord() String?

Available on String, provided by the StringTextExtensions extension

Returns the second word of this string, or null if fewer than two words. Audited: 2026-06-12 11:26 EDT
splitCapitalizedUnicode({bool splitNumbers = false, bool splitBySpace = false, int minLength = 1}) List<String>

Available on String, provided by the StringTextExtensions extension

Returns a list of segments split at capitalized letters (Unicode-aware).
trimLines() String

Available on String, provided by the StringTextExtensions extension

Returns a new string with each line trimmed and empty lines removed. Audited: 2026-06-12 11:26 EDT
trimWithEllipsis({int minLength = 5}) String

Available on String, provided by the StringTextExtensions extension

Returns a truncated version of this string with ellipsis, keeping the first and last minLength characters. Audited: 2026-06-12 11:26 EDT
words() List<String>?

Available on String, provided by the StringTextExtensions extension

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