StringScrewdriver extension
Provides extensions for String.
- on
Properties
- capitalized → String
-
Converts the first character of this to upper case.
Note that this does not work if the first character of this string is
an Emoji character.
no setter
- isBinary → bool
-
Returns true if this is a binary string which only contains 1's and 0's
no setter
- isBlank → bool
-
Returns true if this only contains white-spaces.
no setter
- isDecimal → bool
-
Returns true if this is an int
no setter
- isDouble → bool
-
Returns true if this is a double
no setter
- isEmail → bool
-
Returns true if this happens to be an email
This uses RFC822 email validation specs which is widely accepted.
check this: https://regexr.com/2rhq7
Original Ref: https://www.ietf.org/rfc/rfc822.txt
no setter
- isHexadecimal → bool
-
Returns true if this is a hex string which only
contains 0-9 and A-F | a-f
no setter
- isNotBlank → bool
-
Returns true if this contains characters other than white-spaces.
no setter
- isOctal → bool
-
Returns true if this is a hex string which only
contains 0-7
no setter
- reversed → String
-
Returns a reversed string of this
no setter
- toggledCase → String
-
Toggles the case of the characters
no setter
-
words
→ List<
String> -
This would tokenize this into words by breaking it with space.
no setter
Methods
-
count(
String match, {bool caseSensitive = true}) → int -
Returns count of given
match
in this string -
equalsIgnoreCase(
String matcher) → bool - Compares two strings ignoring the case.
-
find(
Pattern match) → int - alias for indexOf
-
parseJson(
) → Map< String, dynamic> - Converts this to a JSON map.
-
parseJsonArray(
) → List< Map< String, dynamic> > - Converts this to a JSON map.
-
removePrefix(
String prefix) → String -
removes
prefix
from this and returns remaining. e.g. 'hello-world'.removePrefix('hello'); // returns -world 'hello-world'.removePrefix('world'); // returns hello-world -
removeSuffix(
String suffix) → String -
removes
suffix
from this and returns remaining. e.g. 'hello-world'.removeSuffix('world'); // returns hello- 'hello-world'.removeSuffix('hello'); // returns hello-world -
splitMap<
R> (RegExp regex, {R? onMatch(RegExpMatch match)?, R? onNonMatch(String text)?}) → List< R> -
An alternative to String.splitMapJoin which allows to return mapped
values from
onMatch
andonNonMatch
callbacks unlike the original String.splitMapJoin which only allows to return String values. -
splitMapJoinRegex(
RegExp regex, {String onMatch(RegExpMatch match)?, String onNonMatch(String text)?}) → String - An alternative to String.splitMapJoin which provides access to RegExpMatch instead of Match. Match does not provide access to named groups. RegExpMatch does. Reference: https://github.com/dart-lang/sdk/issues/52721
-
title(
) → String - Makes all the words capitalized in this string Note that this does not work properly if the first character of any word is an Emoji character.
-
toBoolOrNull(
) → bool? - Returns true only if this equals to be true (insensitive of case) or if a non-zero integer.
-
toDateTimeOrNull(
) → DateTime? - Tries to convert this into a DateTime.
-
toDoubleOrNull(
) → double? - Returns this as double or null
-
toIntOrNull(
{int? radix}) → int? - Returns this as int or null Radix be between 2..36
-
unwrap(
String prefix, [String? suffix]) → String -
unwraps this between
prefix
andsuffix
. Usesprefix
assuffix
ifsuffix
is null. e.g. 'hello'.unwrap("*"); // returns hello ''.unwrap('<','>'); // returns html -
wrap(
String prefix, [String? suffix]) → String -
wraps this between
prefix
andsuffix
. Usesprefix
assuffix
ifsuffix
is null. e.g. 'hello'.wrap("*"); // returns hello 'html'.wrap('<','>'); // returns