Skip to content

Bug: Deleting Offline Video During Download Crashes Application #18

@windoze95

Description

@windoze95

Description

In lib/services/offline_service.dart, the removeOfflineVideo method calls await _box.delete(videoId) but does not cancel the active download via cancelDownload(videoId).

  Future<void> removeOfflineVideo(String videoId) async {
    ... 
    await _box.delete(videoId);
  }

Impact

If a user triggers deletion while a video is actively downloading, the Dio process continues running in the background. When onReceiveProgress fires, it runs (_box.get(videoId) as Map). Since the box entry was deleted, this throws a type 'Null' is not a subtype of type 'Map<dynamic, dynamic>' in type cast exception, crashing the application.

Suggested Fix

Explicitly invoke cancelDownload(videoId) inside the removeOfflineVideo method to ensure background Dio requests are aborted before the box entry is deleted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions