String in dart is a sequence of UTF-16 characters. The String class comes with a lot of different methods. In this post, we are listing these methods below with a short description for each.
It converts all characters of the string to lowercase. If the string already has all lowercase characters, it returns the same string.
Same as above. The only difference is that it converts all characters to uppercase. If all characters are already uppercase, it returns the same string.
Returns a boolean value true or false based on the string contains a substring or not.
Replaces all substring that matches s1 with s2.
It uses one Match to compute a string that will replace all strings matched with s1.
It replaces the first matched string with s1. That string is replaced by s2. Optionally, we can also provide one start index to search in the string.
This method is also used to replace the first occurrence of a substring in a string. It uses Match to produce the new string. Optionally, we can define the start index to search in the string.
This method is used to replace a specific part of a string defined by the startIndex and endIndex.
It removes the leading and trailing whitespace of a string and returns one new string.
It removes the leading whitespace characters of a string and returns one new string.
It removes the trailing whitespace characters of a string and returns one new string.
Here, width is the required width of the string. If it is shorter than this width, pad this with the optional string s. Returns the new string.
Similar to the above one. The only difference is that it pads to the right.
It returns the index of a pattern p in a string. It checks for the pattern in the string starting from startIndex, which is optional.
This is similar to the above. The only difference is that it returns the last index.
Splits the string using a pattern and returns one list of strings.
This method splits the string, converts its split parts and create one new string by combining them. It returns that string.
Returns a boolean if the string starts with a pattern p. Optionally, we can also send one index as the starting point for the search.
Returns one boolean value if the string ends with a substring s.
Returns one substring starts from start index i and ends at end index j. The end index is optional.
Match a pattern against a string repeatedly.
Match a pattern against the start of a string.
Compares a string with another string. It returns one integer value.
Find the code unit at any index position i.
Get the string representation value of this object.
Invokes if we try to access a non-existing method or non-existing property.