StringExtensions extension

Extensions for presentation, like adding quotes, truncating text, and formatting.

on

Properties

reversed → String

Available on String, provided by the StringExtensions extension

Returns a new string with all characters reversed, by Unicode code point (rune). Surrogate-pair characters survive intact, but grapheme CLUSTERS are NOT preserved: a base letter plus a combining mark, or a ZWJ/skin-tone emoji sequence, is reordered or split (e.g. e+U+0301 reverses to a leading combining acute). Reverse over characters if cluster integrity matters. Audited: 2026-06-12 11:26 EDT
no setter

Methods

encloseInParentheses({bool wrapEmpty = false}) → String?

Available on String, provided by the StringExtensions extension

Returns this string enclosed in parentheses, or null if empty.
insertNewLineBeforeBrackets() → String

Available on String, provided by the StringExtensions extension

Returns a new string with a newline character inserted before each opening parenthesis. Audited: 2026-06-12 11:26 EDT
last(int len) → String

Available on String, provided by the StringExtensions extension

Returns the last len grapheme clusters of this string.
lastChars(int n) → String

Available on String, provided by the StringExtensions extension

Get the last n graphemes (user-perceived characters) of a string.
nullIfEmpty({bool trimFirst = true}) → String?

Available on String, provided by the StringExtensions extension

Returns null if the string is empty or contains only whitespace.
substringSafe(int start, [int? end]) → String

Available on String, provided by the StringExtensions extension

Safely gets a substring, preventing RangeError (returns empty string for out-of-bounds indices). Prefer this over String.substring when indices may be invalid (e.g. user input or variable length).
truncateWithEllipsis(int? cutoff) → String

Available on String, provided by the StringExtensions extension

Returns the string truncated to cutoff graphemes with an ellipsis appended.
truncateWithEllipsisPreserveWords(int? cutoff) → String

Available on String, provided by the StringExtensions extension

Returns the string truncated to cutoff graphemes with an ellipsis, preserving whole words.
wrap({String? before, String? after}) → String

Available on String, provided by the StringExtensions extension

Returns this string wrapped with before prepended and after appended. Audited: 2026-06-12 11:26 EDT
wrapDoubleAccentedQuotes({bool quoteEmpty = false}) → String

Available on String, provided by the StringExtensions extension

Returns this string wrapped in accented double quotes.
wrapDoubleQuotes({bool quoteEmpty = false}) → String

Available on String, provided by the StringExtensions extension

Returns this string wrapped in double quotes: "string".
wrapSingleAccentedQuotes({bool quoteEmpty = false}) → String

Available on String, provided by the StringExtensions extension

Returns this string wrapped in accented single quotes.
wrapSingleQuotes({bool quoteEmpty = false}) → String

Available on String, provided by the StringExtensions extension

Returns this string wrapped in single quotes: 'string'.
wrapWith({String? before, String? after}) → String?

Available on String, provided by the StringExtensions extension

Returns this string wrapped with before prepended and after appended, or null if the string is empty. Audited: 2026-06-12 11:26 EDT

Constants

accentedDoubleQuoteClosing → const String
Right double curly quotation mark ("smart" closing double quote, U+201D).
accentedDoubleQuoteOpening → const String
Left double curly quotation mark ("smart" opening double quote, U+201C).
accentedQuoteClosing → const String
Right single curly quotation mark ("smart" closing quote, U+2019).
accentedQuoteOpening → const String
Left single curly quotation mark ("smart" opening quote, U+2018).
apostrophe → const String
Typographic apostrophe (U+2019), preferred over the straight ASCII quote.
blank → const String
Hangul filler (U+3164), a whitespace-like glyph that survives UI trimming where a normal space would be collapsed.
bullet → const String
Bullet point character.
commonWordEndings → const List<String>
Common word-ending characters for text processing.
dot → const String
Alias for bullet.
dotJoiner → const String
A dot with spaces for joining items (e.g., "Item 1 • Item 2").
doubleChevron → const String
Right-pointing double angle quotation mark "\u00BB" (U+00BB).
ellipsis → const String
Horizontal ellipsis character (U+2026), the single-glyph "\u2026".
hyphen → const String
Unicode hyphen (U+2010), the typographically correct hyphen glyph.
lineBreak → const String
Alias for newLine; reads more naturally when joining display text.
newLine → const String
Line feed character (\n) used to separate lines of text.
nonBreakingHyphen → const String
For not breaking words into newline at hyphen in Text.
nonBreakingSpace → const String
Non-breaking space (U+00A0); keeps adjacent words on the same line.
softHyphen → const String
Soft Hyphen character (U+00AD). Insert into strings to suggest word break points for automatic hyphenation by Flutter's text rendering engine.
zeroWidth → const String
'This\u200Bis\u200Ba\u200Bsentence\u200Bwith\u200Bzero-width\u200Bspaces.