Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Future<void> downloadFile(String name, String uuid) async {
- final _localPath = (await findLocalPath()) + Platform.pathSeparator + 'Download';
- final savedDir = Directory(_localPath);
- bool hasExisted = savedDir.existsSync();
- if (!hasExisted) {
- savedDir.createSync();
- }
- await Dio().download(
- '${url}',
- '$_localPath/$name',
- options: Options(
- method: 'POST',
- headers: <String, dynamic>{'Content-Type': 'application/json'}),
- onReceiveProgress: (count, total) {
- downloadingMessages[uuid] = count / total;
- notifyListeners();
- },
- );
- downloadingMessages.remove(uuid);
- downloadedMessages[uuid] = '$_localPath/$name';
- notifyListeners();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement