The syntax of String.toUpperCase() method is:
String toUpperCase()
This toUpperCase() method of String converts all characters in this string to upper case.
String.toUpperCase() returns value of type String
.
In this example,
str
with the value 'Hello, World!'.toUpperCase()
method to convert all characters in the string to uppercase.upperCaseStr
.void main() {
String str = 'Hello, World!';
String upperCaseStr = str.toUpperCase();
print('Original String: $str');
print('Uppercase String: $upperCaseStr');
}
Original String: Hello, World! Uppercase String: HELLO, WORLD!
In this example,
str
with the value 'abcdef'.toUpperCase()
method to convert all characters in the string to uppercase.upperCaseStr
.void main() {
String str = 'abcdef';
String upperCaseStr = str.toUpperCase();
print('Original String: $str');
print('Uppercase String: $upperCaseStr');
}
Original String: abcdef Uppercase String: ABCDEF
In this example,
str
with the value 'Lorem ipsum dolor sit amet'.toUpperCase()
method to convert all characters in the string to uppercase.upperCaseStr
.void main() {
String str = 'Lorem ipsum dolor sit amet';
String upperCaseStr = str.toUpperCase();
print('Original String: $str');
print('Uppercase String: $upperCaseStr');
}
Original String: Lorem ipsum dolor sit amet Uppercase String: LOREM IPSUM DOLOR SIT AMET
In this Dart tutorial, we learned about toUpperCase() method of String: the syntax and few working examples with output and detailed explanation for each example.