copyUrlToLocalStorageWithProgress method

  1. @override
Stream<int> copyUrlToLocalStorageWithProgress(
  1. String url,
  2. String targetName
)
override

Downloads the file at url to targetName, emitting download progress as integers from 0 to 100.

Implementation

@override
Stream<int> copyUrlToLocalStorageWithProgress(String url, String targetName) {
  _getLocalFilePath(targetName).then(
    (targetPath) => methodChannel.invokeMethod('copyUrlToLocalWithProgress', {
      'url': url,
      'targetPath': targetPath,
    }),
  );

  return progressChannel
      .receiveBroadcastStream()
      .map((event) => event as int);
}