download method

  1. @override
Future<ParseFile> download({
  1. ProgressCallback? progressCallback,
})
override

Implementation

@override
Future<ParseFile> download({ProgressCallback? progressCallback}) async {
  if (url == null) {
    return this;
  }

  file = File('${ParseCoreData().fileDirectory}/$name');
  await file!.create();

  progressCallback ??= _progressCallback;

  _cancelToken = CancelToken();

  final ParseNetworkByteResponse response = await _client.getBytes(
    url!,
    onReceiveProgress: progressCallback,
    cancelToken: _cancelToken,
  );
  await file!.writeAsBytes(response.bytes!);

  return this;
}