🇵🇸 #FreePalestine
Menu

Convert String to Lower Case and Upper Case in Dart

1 min read
Convert String to Lower Case and Upper Case in Dart

The Dart language has simple ways to change the cases of Strings.

To convert a given string to lower case, we can use the toLowerCase() method. It will convert all the characters in the given string to lower case.

String givenString = "This MAy LoOk aWkwaRd";

var resultantString = givenString.toLowerCase(); //
print(resultantString); // "this may look awkward"

The above code will print this may look awkward to the console.

Similarly, To convert a given string to upper case, we can use the toUpperCase method. It will convert all the characters in the given string to upper case.

String givenString = "This MAy LoOk aWkwaRd";

var resultantString = givenString.toUpperCase(); //
print(resultantString); // "THIS MAY LOOK AWKWARD"

The above code will print THIS MAY LOOK AWKWARD to the console.