Skip to content

_removeCachedFile Null check operator used on a null value #297

@creativecreatorormaybenot

Description

🐛 Bug Report

When I call removeFile, the plugin throws the following exception.

[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: Null check operator used on a null value
E/flutter (13327): #0      CacheStore._removeCachedFile (package:flutter_cache_manager/src/cache_store.dart:171:32)
E/flutter (13327): #1      CacheStore.removeCachedFile (package:flutter_cache_manager/src/cache_store.dart:163:15)
E/flutter (13327): <asynchronous suspension>
E/flutter (13327): #2      CacheManager.removeFile (package:flutter_cache_manager/src/cache_manager.dart:276:7)
E/flutter (13327): <asynchronous suspension>

Expected behavior

The cached file should be removed but is not (instead, the exception is thrown).

Reproduction steps

  1. Call DefaultCacheManager().removeFile(fileKey);.

Then the exception is thrown.

I assume this has to be the plugin's fault (looking at the source code) because the object seems to be valid according to this check:

Then here it fails (line 171 in cache_store.dart:

    toRemove.add(cacheObject.id!);

Note that it fails with the null safe version, which I cannot seem to find here on GitHub.

Configuration

Version: flutter_cache_manager: ^3.0.0-nullsafety.1

Platform:

  • 📱 iOS
  • 🤖 Android

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions