fluttercommunity / flutter_downloader

Flutter Downloader - A plugin for creating and managing download tasks.
https://pub.dev/packages/flutter_downloader
BSD 3-Clause "New" or "Revised" License
904 stars 508 forks source link

[Easy fix] Issue with multiple isolates and FlutterDownloader.registerCallback #306

Open EArminjon opened 4 years ago

EArminjon commented 4 years ago

Hi,

I work with multiple isolates and each one is scheduled with AlarmManager (https://pub.dev/packages/android_alarm_manager) and each one can start task with FlutterDownloader. As you known, we must not register multiple ports to an isolate name.

So we have an issue around FlutterDownloader.registerCallback(downloadCallback); The callback must take an other parameter "isolateNameServer";

Actually this is my callback

static void downloadCallback(String id, DownloadTaskStatus status, int progress) {
    final SendPort send = IsolateNameServer.lookupPortByName('downloader_send_port');
    print("Task: $id, status: $status, progress $progress");
    send.send([id, status, progress]);
  }

As the callback is a static we can't change his port name.

Is this little upgrade possible ?

kareemX commented 4 years ago

I'm having the same issue have you found a solution?