loop method Null safety

Stream<String> loop()

Runs a shell prompt in a loop.

Implementation

Stream<String> loop() {
  var controller = StreamController<String>();

  var doRead;

  doRead = () {
    if (_stop) {
      _stop = false;
      return;
    }
    Prompter(message).prompt().then((it) {
      controller.add(it);
      Future(doRead);
    });
  };

  Future(doRead);

  return controller.stream;
}