Remove spaces at both ends
Remove the spaces before and after a name. A space between two words stays in place. These examples use ordinary spaces.
String.trim
Simple example
Trim the single letter.
Start' a '
Resulta
void main() {
print(" a ".trim());
}
a
Advertisements
Everyday examples
Remove the extra spaces copied around a ticket number.
Start' B12 '
ResultB12
void main() {
print(" B12 ".trim());
}
B12
Clean up the outside spaces on a shelf label.
Start' Red Apples '
ResultRed Apples
void main() {
print(" Red Apples ".trim());
}
Red Apples
Clean up a name copied from a signup sheet.
Start' Ana '
ResultAna
void main() {
print(" Ana ".trim());
}
Ana