readLineDefault method

Future<String> readLineDefault({
  1. String defaultValue = "",
  2. Encoding encoding = systemEncoding,
  3. bool retainNewlines = false,
})

Executes stdin.readLineSync in a different Isolate then the calling one. Therefore this method does not block the event loop of the calling Isolate.

This method is the same as readLine, but it returns defaultValue instead of null.

The returned Future completes with an error containing an IsolatedStdinDisposedException, if the Isolate is disposed (see dispose) before this request is finshed.

See Stdin.readLineSync

Implementation

Future<String> readLineDefault({
  String defaultValue = "",
  Encoding encoding = systemEncoding,
  bool retainNewlines = false,
}) {
  return readLine(
    encoding: encoding,
    retainNewlines: retainNewlines,
  ).then((v) => v ?? defaultValue);
}