strip static method

String strip(
  1. String text
)

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;
}