flutter_downloader icon indicating copy to clipboard operation
flutter_downloader copied to clipboard

Negative progress

Open hirosz opened this issue 1 year ago • 3 comments

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<void> _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<dynamic>)[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);

      }
    });
  }

hirosz avatar May 22 '24 23:05 hirosz

@hirosz can you send me what you're trying to download ?

salmaahhmed avatar May 23 '24 10:05 salmaahhmed

@hirosz can you send me what you're trying to download ?

zip file from firebase hosting: https://superstories-7538f.web.app/models/modelen.zip

hirosz avatar May 23 '24 10:05 hirosz

moved to AWS and now it's ok

hirosz avatar May 23 '24 17:05 hirosz