StringUtils class abstract

Util class for operations on strings.

Constructors

StringUtils()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

abbreviate(String str, int maxWidth, {int offset = 0}) String
Abbreviates a string with maxWidth using dots. If offset is set the Examples:
compare(String? str1, String? str2) int
Null safe comparison of two strings according their lexical order. null it is treated as less than non-null.
contains(String? str, Pattern searchPattern, [int startIndex = 0]) bool
Null safe check if a string contains searchPattern.
containsAny(String? str, List<Pattern> searchPatterns, [int startIndex = 0]) bool
Null safe check if a string contains any of searchPatterns.
defaultIfBlank(String? str, String defaultStr) String
Returns the string itself or a default if the string is null or blank.
defaultIfEmpty(String? str, String defaultStr) String
Returns the string itself or a default if the string is null or empty.
defaultString(String? str, String defaultStr) String
Returns the string itself or a default if the string is null.
hammingDistance(String str1, String str2) int
Calculates the hamming distance between two strings. The hamming distance is the number of positions where two strings have different chars.
isBlank(String? str) bool
Null safe check if string is blank.
isEmpty(String? str) bool
Null safe check if string is empty.
levenshteinDistance(String str1, String str2) int
Calculates the levenshtein distance between two strings. The levenshtein distance is the number of deletions, insertions or substitutions needed to transform one string into the other.
random({int? length, bool includeNumeric = true}) String
Creates a random alpha numeric string with a random length between 1 and 64. For a specific length length can be set. If includeNumeric is set to false a string with only alpha characters is generated.
startsWith(String? str, Pattern prefix, [int index = 0]) bool
Null safe check if a string starts with prefix.
startsWithAny(String? str, List<Pattern> prefixes, [int index = 0]) bool
Null safe check if a string starts with any of prefixes.
trim(String? str) String?
Null safe trim operation on a string.