fetch function
- required String url,
- required String saveToPath,
- OnFetchProgress fetchProgress = _devNull,
Fetches the given resource at the passed url
.
fetch(url: 'https://some/resource/file.zip', saveToPath: '/tmp/file.zip');
The url
must be a http or https based resource.
The saveToPath
may be an absolute (recommended) or relative path where to
save the downloaded resource.
The file at saveToPath
must NOT exist. If it does a FetchException
will be thrown.
You may optionally passing in a fetchProgress
method which will be
called each
time a chunk is downloaded with details on the download progress.
We guarentee that you will recieve a final event with the
FetchProgress.progress
containing a value of 1.0 and a status of 'complete'.
In the future we MAY allow you to cancel the download part way
through by returning false
to the fetchProgress
call. In the meantime ensure that you
always return true from
the 'onProgress' callback.
Implementation
void fetch(
{required String url,
required String saveToPath,
OnFetchProgress fetchProgress = _devNull}) =>
_Fetch().fetch(url: url, saveToPath: saveToPath, progress: fetchProgress);