Dart

Dart String Methods

Dart String Methods

Dart string methods are built-in methods for manipulating and working with strings, a fundamental data type consisting of a sequence of characters.

Dart Strings can be created using single quotes or double quotes, i.e., characters enclosed within single (‘) or double (“) quotes. Strings are immutable in the Dart language, which means that we cannot modify them after they are created.

Dart String 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/