getFile method

Future<void> getFile(
  1. PathUri path,
  2. File file, {
  3. void onProgress(
    1. double progress
    )?,
})

Retrieves the content of the file at path.

onProgress can be used to watch the download progress. Possible values range from 0.0 to 1.0.

If the response is empty the file will be created with no data.

See:

Implementation

Future<void> getFile(
  PathUri path,
  File file, {
  void Function(double progress)? onProgress,
}) async {
  final sink = file.openWrite();
  final stream = await getStream(
    path,
    onProgress: onProgress,
  );
  await stream.pipe(sink);
  await sink.close();
}