normalizeWhitespace function

String normalizeWhitespace(
  1. String text
)

Collapse runs of whitespace into single spaces and trim.

Implementation

String normalizeWhitespace(String text) {
  return text.replaceAll(RegExp(r'\s+'), ' ').trim();
}