Dart – Convert String to Uppercase
To convert a given string to uppercase in Dart, call toUpperCase() method on this string.
toUpperCase() method converts all the characters in this string to uppercase and returns the resulting string.
Syntax
The syntax to call toUpperCase() method on this string object str
is
</>
Copy
str.toUpperCase()
Example
In this example, we take a string and convert this string to uppercase using String.toUpperCase() method.
main.dart
</>
Copy
void main() {
var str = 'Hello World';
var result = str.toUpperCase();
print(result);
}
Output
HELLO WORLD
Conclusion
In this Dart Tutorial, we learned how to convert a given string to uppercase, using toUpperCase() method of String class, with examples.