collapseWhitespace static method

String collapseWhitespace(
  1. String input
)

Collapses every run of whitespace (spaces, tabs, newlines) to a single space and trims the result. Used to compare code that dart format may have re-indented or wrapped across multiple physical lines, so matching stays stable regardless of formatting.

Implementation

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