StringCustomFunctionExtensions extension

String common function extensions

on

Properties

capitalize String

Available on String, provided by the StringCustomFunctionExtensions extension

Capitalizes the first letter of the string. Returns the original string if it is empty.
no setter
removeAllSpaces String

Available on String, provided by the StringCustomFunctionExtensions extension

Removes all spaces from the string.
no setter
reversed String

Available on String, provided by the StringCustomFunctionExtensions extension

Reverses the string.
no setter

Methods

insert(int index, String str) String

Available on String, provided by the StringCustomFunctionExtensions extension

Inserts the string str at the specified index within the original string. Throws RangeError if index is out of bounds.
onEmpty(String? val) String?

Available on String, provided by the StringCustomFunctionExtensions extension

Returns a provided alternative string val if the original string is empty. If val is null, it defaults to an empty string.
repeat(int times) String

Available on String, provided by the StringCustomFunctionExtensions extension

Repeats the string times number of times.
replaceFirst(String from, String replace) String

Available on String, provided by the StringCustomFunctionExtensions extension

Replaces the first occurrence of the substring from with replace. If from is not found in the string, returns the original string.
replaceLast(String from, String to) String

Available on String, provided by the StringCustomFunctionExtensions extension

Replaces the last occurrence of the substring from with to. If from is not found in the string, returns the original string.
safeSubstring(int startIndex, int endIndex) String

Available on String, provided by the StringCustomFunctionExtensions extension

安全地截取字符串,如果字符串长度不够,则返回原字符串。
toEnum<T>(List<T> enumValues) → T?

Available on String, provided by the StringCustomFunctionExtensions extension

Tries to parse the string into a specified enum type T. Returns null if the parsing fails. This method requires the list of all enum values enumValues to check against.