initialize method

Future<bool> initialize()

Implementation

Future<bool> initialize() async {
  // `exitCode` can complete before the output is fully read: record the
  // exit only after the output (or 5s, if a stream never closes).
  // ignore: unawaited_futures
  process.exitCode.then((exitCode) async {
    await Future.wait(_outputsDone.map((c) => c.future))
        .timeout(Duration(seconds: 5), onTimeout: () => []);
    _setExitCode(exitCode);
  });

  var anyOutputReadyCompleter = Completer<bool>();

  setupStdout(_buildOutputStream(OutputStreamType.stdout, process.stdout,
      _stdoutReadyFunction, anyOutputReadyCompleter));
  setupStderr(_buildOutputStream(OutputStreamType.stderr, process.stderr,
      _stderrReadyFunction, anyOutputReadyCompleter));
  setupOutputReadyType(_outputReadyType);

  return true;
}