normalizeWhitespace method

String normalizeWhitespace()

Collapses consecutive whitespace into single spaces and trims the result.

Example: " Line 1 \n Line 2 " => "Line 1 Line 2"

Implementation

String normalizeWhitespace() => trim().replaceAll(RegExp(r'\s+'), ' ');