How to read console input on M3 Dart

console, dart, stdin, stream

Solution

Try this:

import 'dart:io';
import 'dart:async';

void main() {
  print("Please, enter a line \n");
  Stream cmdLine = stdin
      .transform(new StringDecoder())
      .transform(new LineTransformer());

  StreamSubscription cmdSubscription = cmdLine.listen(
    (line) => print('Entered line: $line '),
    onDone: () => print(' finished'),
    onError: (e) => /* Error on input. */);


}

Problem

With M3 the classes like StringInputStream are replaced with Stream. How can I read stdin input on a server application?

Original source