StringFormattingAndWrappingExtensions extension
Extensions for presentation, like adding quotes, truncating text, and formatting.
- on
Properties
- reversed → String
-
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Reverses the characters in the string. Handles Unicode characters correctly.no setter
Methods
-
compressSpaces(
{bool trim = true}) → String? -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Extension method to remove consecutive spaces in a String and optionally trim the result. This is an alias for removeConsecutiveSpaces. -
containsIgnoreCase(
String? other) → bool -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Checks if this string containsother
in a case-insensitive manner. -
encloseInParentheses(
{bool wrapEmpty = false}) → String? -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Extension method to enclose a String in parentheses. -
escapeForRegex(
) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Escapes characters in a string that have a special meaning in regular expressions. -
getEverythingAfter(
String find) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Returns the substring after the first occurrence offind
. Returns the original string iffind
is not found. -
getEverythingAfterLast(
String find) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Returns the substring after the last occurrence offind
. Returns the original string iffind
is not found. -
getEverythingBefore(
String find) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Returns the substring before the first occurrence offind
. Returns the original string iffind
is not found. -
getFirstDiffChar(
String other) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
-
insert(
String newChar, int position) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
InsertsnewChar
at the specifiedposition
. -
insertNewLineBeforeBrackets(
) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Inserts a newline character before each opening parenthesis. -
isBracketWrapped(
) → bool -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Checks if the string starts and ends with matching brackets. e.g.,(abc)
,[abc]
,{abc}
,<abc>
. -
isEquals(
String? other, {bool ignoreCase = true, bool normalizeApostrophe = true}) → bool -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Compares this string toother
, with options for case-insensitivity and apostrophe normalization. -
isLatin(
) → bool -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Checks if the string contains only Latin alphabet characters (a-z, A-Z). -
lastChars(
int n) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Get the lastn
characters of a string. -
normalizeApostrophe(
) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Replaces different apostrophe characters (’ and ') with a standard single quote. -
nullIfEmpty(
{bool trimFirst = true}) → String? -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Returnsnull
if the string is empty or contains only whitespace. -
removeConsecutiveSpaces(
{bool trim = true}) → String? -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Extension method to remove consecutive spaces in a String and optionally trim the result. -
removeEnd(
String end) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Removesend
from the end of the string, if it exists. -
removeFirstChar(
) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Removes the first character from the string. -
removeFirstLastChar(
) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Removes both the first and the last character from the string. -
removeLastChar(
) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Removes the last character from the string. -
removeLastOccurrence(
String target) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Removes the last occurrence oftarget
from the string. -
removeMatchingWrappingBrackets(
) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Removes the first and last characters if they are a matching pair of brackets. -
removeNonAlphaNumeric(
{bool allowSpace = false}) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Removes all characters that are not letters or numbers. -
removeNonNumbers(
) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Removes all characters that are not digits (0-9). -
removeStart(
String? start, {bool isCaseSensitive = true, bool trimFirst = false}) → String? -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Returns a new string with the specifiedstart
removed from the beginning of the original string, if it exists. -
removeWrappingChar(
String char, {bool trimFirst = true}) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Removes the specifiedchar
from the beginning and/or end of the string. -
replaceNonNumbers(
{String replacement = ''}) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Replaces all characters that are not digits (0-9) with thereplacement
string. -
splitCapitalizedUnicode(
{bool splitNumbers = false, bool splitBySpace = false, int minLength = 1}) → List< String> -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Splits a string by capitalized letters (Unicode-aware) and optionally by spaces, with an option to prevent splits that result in short segments. -
substringSafe(
int start, [int? end]) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Safely gets a substring, preventing RangeError. -
toAlphaOnly(
{bool allowSpace = false}) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Removes all characters that are not letters (A-Z, a-z). -
truncateWithEllipsis(
int? cutoff) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Truncates the string tocutoff
and appends an ellipsis '…'. -
truncateWithEllipsisPreserveWords(
int? cutoff) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Truncates the string tocutoff
and appends an ellipsis '…'. -
words(
) → List< String> ? -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Splits the string into a list of words, using space (" ") as the delimiter. -
wrap(
{String? before, String? after}) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Wraps the string with the givenbefore
andafter
strings. -
wrapDoubleAccentedQuotes(
{bool quoteEmpty = false}) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Return a string wrapped in “accented quotes” -
wrapDoubleQuotes(
{bool quoteEmpty = false}) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Wraps the string in double quotes:"string"
. -
wrapSingleAccentedQuotes(
{bool quoteEmpty = false}) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Return a string wrapped in ‘accented quotes’ -
wrapSingleQuotes(
{bool quoteEmpty = false}) → String -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Wraps the string in single quotes:'string'
. -
wrapWith(
{String? before, String? after}) → String? -
Available on String, provided by the StringFormattingAndWrappingExtensions extension
Extension method to wrap a String with a prefixbefore
and a suffixafter
. Returns null if the string is empty.
Constants
- accentedDoubleQuoteClosing → const String
- accentedDoubleQuoteOpening → const String
- accentedQuoteClosing → const String
- accentedQuoteOpening → const String
- apostrophe → const String
- blank → const String
- 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. It's invisible unless a break occurs at its position.
- zeroWidth → const String
- 'This\u200Bis\u200Ba\u200Bsentence\u200Bwith\u200Bzero-width\u200Bspaces.