expectedFileSize method
Return the expected file size for this task, or -1 if unknown
The expected file size is obtained by making a HEAD request to the url represented by the DownloadTask, including urlQueryParameters and headers
Implementation
Future<int> expectedFileSize() async {
try {
final response = await DesktopDownloader.httpClient
.head(Uri.parse(url), headers: headers);
if ([200, 201, 202, 203, 204, 205, 206].contains(response.statusCode)) {
return getContentLength(response.headers, this);
}
} catch (e) {
// no content length available
}
return -1;
}