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.
Description
In
lib/services/offline_service.dart, theremoveOfflineVideomethod callsawait _box.delete(videoId)but does not cancel the active download viacancelDownload(videoId).Impact
If a user triggers deletion while a video is actively downloading, the Dio process continues running in the background. When
onReceiveProgressfires, it runs(_box.get(videoId) as Map). Since the box entry was deleted, this throws atype 'Null' is not a subtype of type 'Map<dynamic, dynamic>' in type castexception, crashing the application.Suggested Fix
Explicitly invoke
cancelDownload(videoId)inside theremoveOfflineVideomethod to ensure background Dio requests are aborted before the box entry is deleted.