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. Handles Unicode correctly.no setter
Methods
-
encloseInParentheses(
{bool wrapEmpty = false}) → String? -
Available on String, provided by the StringExtensions extension
Returns this string enclosed in parentheses, ornullif empty. -
insertNewLineBeforeBrackets(
) → String -
Available on String, provided by the StringExtensions extension
Returns a new string with a newline character inserted before each opening parenthesis. -
last(
int len) → String -
Available on String, provided by the StringExtensions extension
Returns the lastlengrapheme clusters of this string. -
lastChars(
int n) → String -
Available on String, provided by the StringExtensions extension
Get the lastngraphemes (user-perceived characters) of a string. -
nullIfEmpty(
{bool trimFirst = true}) → String? -
Available on String, provided by the StringExtensions extension
Returnsnullif 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 tocutoffgraphemes with an ellipsis appended. -
truncateWithEllipsisPreserveWords(
int? cutoff) → String -
Available on String, provided by the StringExtensions extension
Returns the string truncated tocutoffgraphemes with an ellipsis, preserving whole words. -
wrap(
{String? before, String? after}) → String -
Available on String, provided by the StringExtensions extension
Returns this string wrapped withbeforeprepended andafterappended. -
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 withbeforeprepended andafterappended, ornullif the string is empty.
Constants
- accentedDoubleQuoteClosing → const String
- accentedDoubleQuoteOpening → const String
- accentedQuoteClosing → const String
- accentedQuoteOpening → const String
- apostrophe → const String
- blank → const String
- 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
- ellipsis → const String
- hyphen → const String
- lineBreak → const String
- newLine → const String
- nonBreakingHyphen → const String
- For not breaking words into newline at hyphen in Text.
- nonBreakingSpace → const String
- 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.