downloadStreamFile static method

Future<void> downloadStreamFile(
  1. String downloadPath,
  2. Stream<List<int>> stream
)

下载流文件

Implementation

static Future<void> downloadStreamFile(String downloadPath, Stream<List<int>> stream) async {
  final file = File(downloadPath);
  final sink = file.openWrite();
  try {
    await stream.forEach((chunk) => sink.add(chunk));
  } catch (e, s) {
    LogService.instance.reportError('下载流文件', e, s);
  } finally {
    await sink.flush();
    await sink.close();
  }
}