Future'sとCompletersを連動して連鎖させることができます。次の未来はprocessから 'ls' のコマンドの結果を返します:あなたは、このように一緒に連鎖することができます
Future<String> fetch(String dir) {
final completer = new Completer();
Process process = new Process.start('ls', [dir]);
process.exitHandler = (int exitCode) {
StringInputStream stringStream = new StringInputStream(process.stdout);
stringStream.dataHandler =() {
String content = stringStream.read();
completer.complete(content);
process.close();
};
};
process.errorHandler = (var error) {
completer.completeException(error);
return true;
};
return completer.future;
};
:。
フェッチ( '/')、その後(( val)=> fetch( "/ usr")。then((val)=> fetch( "/ tmp")));
これは私にとって今最も魅力的な解決策ではありません。