strip static method
Removes extra whitespace
Implementation
static String strip(String text) {
String string = text;
bool hasSpaceAfter = false;
bool hasSpaceBefore = false;
if (string.startsWith(' ')) {
hasSpaceBefore = true;
}
if (string.endsWith(' ')) {
hasSpaceAfter = true;
}
string = string.trim();
if (hasSpaceBefore) string = ' $string';
if (hasSpaceAfter) string = '$string ';
return string;
}