compactWhitespace method
Replaces all runs of whitespace with a single space and trims.
' hello world '.compactWhitespace() // 'hello world'
Implementation
String compactWhitespace() => trim().replaceAll(RegExp(r'\s+'), ' ');
Replaces all runs of whitespace with a single space and trims.
' hello world '.compactWhitespace() // 'hello world'
String compactWhitespace() => trim().replaceAll(RegExp(r'\s+'), ' ');