Strings
String Methods
trim and toUpperCase
Strings are immutable; methods return new strings. trim removes outer whitespace, toUpperCase converts case.
Program
Play the program to clean and uppercase a noisy greeting.
string_methods.dart
void main() {
var text = ' Hello World ';
var clean = text.trim();
var upper = clean.toUpperCase();
print('[$upper]');
}
immutable
Each method returns a fresh string; the original is unchanged.
trim
Removes leading and trailing whitespace.
toUpperCase
Returns an uppercase copy.