replaceLineEndings static method

String replaceLineEndings(
  1. String? string, {
  2. String? replacement = '\n',
})

Replaces line endings with replacement, which defaults to LF ('\n') on every platform. Null input returns ''.

Recognizes CRLF as one ending, plus CR (U+000D), LF (U+000A), NEL (U+0085), FF (U+000C), LS (U+2028) and PS (U+2029). Vertical tab is unchanged. Null or empty replacement removes endings. Replacement is literal and is not processed again; all other code units are preserved.

Implementation

static String replaceLineEndings(
  String? string, {
  String? replacement = '\n',
}) => Transform.replaceLineEndings(string, replacement: replacement);