description

# lineTerminator property

1. @Since.new("3.4")

String get lineTerminator
inherited

Line ending appended by `writeln`, and replacing `"\n"` in some methods.

Must be one of the values `"\n"` (the default) or `"\r\n"`.

When set to `"\r\n"`, the methods `write`, `writeln`, `writeAll` and `writeCharCode` will convert embedded newlines, `"\n"`, in their arguments to `"\r\n"`. If their arguments already contain `"\r\n"` sequences, then these sequences will be not be converted. This is true even if the sequence is generated across different method calls.

If `lineTerminator` is `"\n"` then the written strings are not modified. Setting `lineTerminator` to Platform.lineTerminator will result in "write" methods emitting the line endings for the platform:

    stdout.lineTerminator = Platform.lineTerminator;
    stderr.lineTerminator = Platform.lineTerminator;

The value of `lineTerminator` has no effect on byte-oriented methods such as `add`.

The value of `lineTerminator` does not effect the output of the print function.

The `lineTerminator` must be either `"\n"` or `"\r\n"`.

## Implementation

    //
    /// Setting `lineTerminator` to [Platform.lineTerminator] will result in
    /// "write" methods emitting the line endings for the platform:
    ///
    /// ```dart
    /// stdout.lineTerminator = Platform.lineTerminator;
    /// stderr.lineTerminator = Platform.lineTerminator;
    /// ```
    ///
    /// The value of `lineTerminator` has no effect on byte-oriented methods
    /// such as [add].
    ///
    /// The value of `lineTerminator` does not effect the output of the [print]
    /// function.
    ///
    /// The [lineTerminator] *must* be either `"\n"` or `"\r\n"`.
    @Since("3.4")
    String get lineTerminator => _windowsLineTerminator ? "\r\n" : "\n";

1. @Since.new("3.4")

set lineTerminator (String lineTerminator)
inherited

## Implementation

    @Since("3.4")
    set lineTerminator(String lineTerminator) {
      if (lineTerminator == "\r\n") {
        assert(!_lastWrittenCharIsCR || _windowsLineTerminator);
        _windowsLineTerminator = true;
      } else if (lineTerminator == "\n") {
        _windowsLineTerminator = false;
        _lastWrittenCharIsCR = false;
      } else {
        throw ArgumentError.value(
          lineTerminator,
          "lineTerminator",
          r'invalid line terminator, must be one of "\n" or "\r\n"',
        );
      }
    }