StringUtils class

Helper class for String operations

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 Properties

asciiCodec AsciiCodec
getter/setter pair

Static Methods

addCharAtPosition(String s, String char, int position, {bool repeat = false}) String
Add a char at a position with the given String s.
camelCaseToLowerUnderscore(String s) String
Transfers the given String s from camcelCase to lowerCaseUnderscore Example : helloWorld => hello_world
camelCaseToUpperUnderscore(String s) String
Transfers the given String s from camcelCase to upperCaseUnderscore Example : helloWorld => HELLO_WORLD
capitalize(String s, {bool allWords = false}) String
Capitalize the given string s. If allWords is set to true, it will capitalize all words within the given string s.
chunk(String s, int chunkSize) List<String>
Splits the given String s in chunks with the given chunkSize.
countChars(String s, String char, {bool caseSensitive = true}) int
Counts how offen the given char apears in the given string s. The value caseSensitive controlls whether it should only look for the given char or also the equivalent lower/upper case version. Example: Hello and char l => 2
defaultString(String? str, {String defaultStr = ''}) String
Returns the given string or the default string if the given string is null
equalsIgnoreCase(String a, String b) bool
Compares the given strings a and b.
generateRandomString(int length, {dynamic alphabet = true, dynamic numeric = true, dynamic special = true, dynamic uppercase = true, dynamic lowercase = true, String from = ''}) String
Generates a Random string
generateRandomStrings(int amount, int length, {dynamic alphabet = true, dynamic numeric = true, dynamic special = true, dynamic uppercase = true, dynamic lowercase = true, String from = ''}) List<String>
Generates amount random strings
hidePartial(String s, {int begin = 0, int? end, String replace = '*'}) String?
Replaces chars of the given String s with replace.
inList(String s, List<String> list, {bool ignoreCase = false}) bool
Checks if the given list contains the string s
isAscii(String s) bool
Checks if the given string s contains only ascii chars
isDigit(String s) bool
Checks if the given string s is a digit.
isIP(String s, {InternetAddressType? ipType}) bool
Checks whether the given String s is an IPv4 or IPv6 address.
isLowerCase(String s) bool
Checks if the given string s is lower case
isNotNullOrEmpty(String? s) bool
Checks if the given String s is not null or empty
isNullOrEmpty(String? s) bool
Checks if the given String s is null or empty
isPalindrome(String s) bool
Checks if the given string s is a palindrome Example : aha => true hello => false
isUpperCase(String s) bool
Checks if the given string s is upper case
pickOnly(dynamic value, {int from = 1, int to = -1}) String
Picks only required stringvalue starting from and ending at to
removeCharAtPosition(String value, int index) String
Removes character with index from a String value
removeExp(String value, String pattern, {bool repeat = true, bool caseSensitive = true, bool multiLine = false, bool dotAll = false, bool unicode = false}) String
Remove Stringvalue with pattern
reverse(String s) String
Reverse the given string s Example : hello => olleh
toPascalCase(String s) String
Converts the given String s to PascalCase Example: your name => YourName
truncate(String value, int length, {String symbol = '...'}) String
Takes in a Stringvalue and truncates it with length symbol default is '...' truncate('This is a Dart Utility Library', 26) returns 'This is a Dart Utility Lib...'