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

str.toUpperCase()
ADVERTISEMENT

Example

In this example, we take a string and convert this string to uppercase using String.toUpperCase() method.

main.dart

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.