removeAllWhitespace method

String removeAllWhitespace()

Removes all whitespace characters (spaces, tabs, newlines, etc.) from the string.

Example:

' Hello \n World '.removeAllWhitespace()   // 'HelloWorld'
'a b c'.removeAllWhitespace()              // 'abc'
'  spaced  out  '.removeAllWhitespace()    // 'spacedout'

Implementation

String removeAllWhitespace() {
  return replaceAll(RegExp(r'\s+'), '');
}