Dart String Methods
Overview
Dart string methods are built-in methods that you can use to manipulate and work with strings. Strings are a fundamental data type. A string is a sequence of characters.
Dart String can be created using single quotes or double quotes. i.e. characters enclosed within single (‘) or double (“) quotes. Strings are immutable in Dart language. It means that we cannot modify the string after it’s creation.
Syntax
The String keyword is used to declare the string in Dart programs. The general syntax to declare the string is as follows:
String message = ‘Welcome to TestingDocs.com’;
or
String course_name = “Software Testing” ;
Dart String Methods
The Dart provides an extensive range of methods. The list of a few essential methods is given below.
String Method | Method Description |
toUpperCase() | This method converts all characters of the given string into uppercase. |
toLowerCase() | This method converts all characters of the given string into lowercase. |
compareTo() | This method compares one string to another string. |
trim() | This method eliminates all whitespaces from the given string. |
replaceAll() | This method replaces all substrings that match the specified pattern within the given string. |
substring() | This method returns the substring from the start index, including the end index. |
split() | This method splits the string that matches the specified delimiter and returns the list of the substrings. |
toString() | This method returns the string representation of the given object. |
—
Dart Tutorials
Dart tutorial on this website can be found at:
https://www.testingdocs.com/dart-tutorials-for-beginners/
More information on Dart: