StringExtensions extension
Properties
-
asBool
→ bool
-
Convert this string into boolean.
no setter
-
getTextSize
→ Size
-
no setter
-
isEmptyOrNull
→ bool
-
Return a bool if the string is null or empty
no setter
-
isNotBlank
→ bool
-
Returns true if s is neither null, empty nor is solely made of whitespace characters.
no setter
-
isNullOrWhiteSpace
→ bool
-
Indicates whether a specified string is
null
, empty
, or consists only of white-space
characters.
no setter
-
lastIndex
→ String
-
no setter
-
orEmpty
→ String
-
Returns the string if it is not
null
, or the empty string otherwise
no setter
Methods
-
anyChar(bool predicate(String element))
→ bool
-
Returns
true
if at least one element matches the given predicate
.
the predicate
should have only one character
-
equalsIgnoreCase(String? other)
→ bool
-
-
generateMessageByGender({Gender? gender, Message? message})
→ String
-
-
hasCapitalletter(String s)
→ bool
-
Checks if string contains at least one Capital Letter
-
hasMatch(String? value, String pattern)
→ bool
-
-
ifEmpty(Function action)
→ String?
-
-
insert(int index, String str)
→ String
-
Returns a new string in which a specified string is inserted at a specified index position in this instance.
-
isAlphabetOnly(String s)
→ bool
-
Checks if string consist only Alphabet. (No Whitespace)
-
isAudio(String filePath)
→ bool
-
Checks if string is an audio file.
-
isBlank(dynamic value)
→ bool?
-
Checks if data is null or blank (empty or only contains whitespace).
-
isBool(String value)
→ bool
-
Checks if string is boolean.
-
isCurrency(String s)
→ bool
-
Checks if string is Currency.
-
isEmail(String s)
→ bool
-
Checks if string is email.
-
isHTML(String filePath)
→ bool
-
Checks if string is an html file.
-
isImage(String filePath)
→ bool
-
Checks if string is an image file.
-
isNull(dynamic value)
→ bool
-
-
isNumericOnly(String s)
→ dynamic
-
-
isPalindrom(String string)
→ bool
-
Checks if string is Palindrom.
-
isPhoneNumber(String s)
→ bool
-
Checks if string is phone number.
-
isUsername(String s)
→ bool
-
Checks if string is a valid username.
-
isVideo(String filePath)
→ bool
-
Checks if string is an video file.
-
limitFromEnd(int maxSize)
→ String?
-
Shrink a string to be no more than
maxSize
in length, extending from the end.
For example, in a string with 10 charachters, a maxSize
of 3 would return the last 3 charachters.
-
limitFromStart(int maxSize)
→ String?
-
Shrink a string to be no more than
maxSize
in length, extending from the start.
For example, in a string with 10 charachters, a maxSize
of 3 would return the first 3 charachters.
-
printThis()
→ void
-
prints to console this text if it's not empty or null
-
removeAllWhiteSpace()
→ String?
-
Returns a String without white space at all
"hello world" // helloworld
-
removeSurrounding(String delimiter)
→ String?
-
Return the string only if the delimiter exists in both ends, otherwise it will return the current string
-
replaceAfter(String delimiter, String replacement, [String? defaultValue])
→ String?
-
Replace part of string after the first occurrence of given delimiter with the
replacement
string.
If the string does not contain the delimiter, returns defaultValue
which defaults to the original string.
-
replaceBefore(String delimiter, String replacement, [String? defaultValue])
→ String?
-
Replace part of string before the first occurrence of given delimiter with the
replacement
string.
If the string does not contain the delimiter, returns missingDelimiterValue?
which defaults to the original string.
-
toCharArray()
→ List<String>
-
Returns a list of chars from a String
-
toDoubleOrNull()
→ double?
-
Parses the string as an double or returns
null
if it is not a number.
-
toIntOrNull()
→ int?
-
Parses the string as an int or returns
null
if it is not a number.
-
validateEmail()
→ bool
-
-
wrapString(int afterWords)
→ String
-
afterWords
will add new line after the selected word
Example
'Hi, my name is'.wrapString(2)