如何读取M3飞镖控制台输入(How to read console input on M3 Dart

2019-07-21 17:22发布

与M3一样StringInputStream类被替换流 。 我怎么能读上一个服务器应用程序标准输入的输入?

Answer 1:

试试这个:

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. */);


}


文章来源: How to read console input on M3 Dart