dowload method
void
dowload(
- String urlOrFileId, {
- int? quanlity,
})
Implementation
void dowload(String urlOrFileId, {int? quanlity}) async {
Map<dynamic, dynamic> downloadInfoMap = {
"savePath": savePath,
"urlOrFileId": urlOrFileId,
"appId": appId,
"quanlity": quanlity,
};
await channel.invokeMethod(
'download',
downloadInfoMap,
);
void eventListener(dynamic event) {
if (_isDisposed) {
return;
}
final Map<dynamic, dynamic> map = event;
debugPrint("native to flutter");
debugPrint(map.toString());
DownloadValue downloadValue = DownloadValue.fromJson(map);
if (downloadValue.fileId != null) {
value[downloadValue.fileId!] = downloadValue;
} else {
value[downloadValue.url!] = downloadValue;
}
notifyListeners();
}
_eventSubscription = _eventChannelFor(urlOrFileId).receiveBroadcastStream().listen(eventListener);
}