fluttercommunity / fluttercommunity/flutter_downloader

Negative progress

Open
#956 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
940
Forks
561
Avg merge
1h 18m
Merged PRs (30d)
1

Description

Hi! When i try to dowanload with listen to progress i only get progress: 0, thn some negative value and at the end 100. Nothing in between. What could be wrong?

```

Future _initialize() async {
await _initializePreferences();
refreshDownloadTasks();
bindBackgroundIsolate();
FlutterDownloader.registerCallback(downloadCallback, step: 1);
}

void bindBackgroundIsolate() {
final isSuccess = IsolateNameServer.registerPortWithName(
_port.sendPort,
'downloader_send_port',
);
if (!isSuccess) {
unbindBackgroundIsolate();
bindBackgroundIsolate();
return;
}

_port.listen((dynamic data) async {
final taskId = (data as List)[0] as String;
final status = DownloadTaskStatus.fromInt(data[1] as int);
final progress = data[2] as int;

logger.i(
'Callback on UI isolate: '
'task ($taskId) is in status ($status) and process ($progress)',
);

if (_tasks.isNotEmpty) {
final task = _tasks.firstWhere((task) => task.taskId == taskId);
task
..status = status
..progress = progress;

// Emit the status change

if (status == DownloadTaskStatus.complete) {
await handleZipFile();
refreshDownloadTasks();
}
_downloadStatusController.add(status);

}
});
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.