flutter_cache_manager icon indicating copy to clipboard operation
flutter_cache_manager copied to clipboard

`getFileFromCache` future does not resolve sometimes on android

Open sillydomnom opened this issue 3 years ago • 2 comments

Hey together,

there is an issue with the flutter_cache_manager which is only happening sometimes on android. At this point we are not sure under wich circumstances, but most of the times when something changes on Android (e.g. Application switching, Updating the App version)

My code looks like this:

logMessage(
        'Loading file from cache...',
        extras: {'File': url},
      );
      var file = await _cacheManager.getFileFromCache(url);

      if (file == null) {
        logMessage(
          'File not in cache. Marked for retrieval.',
          extras: {'File': url},
        );
        futures.add(_repository.retrieveAsset(url)
          ..then((file) async {
            logMessage(
              'File successfully retrieved. Caching...',
              extras: {'File': url},
            );
            await _cacheManager.putFile(url, file);
            logMessage(
              'Successfully cached file.',
              extras: {'File': url},
            );
          }));
      } else {
        logMessage(
          'Found file in cache.',
          extras: {'File': url},
        );
      }

The logs are only going until Loading file from cache..., after that the class is never returning any logs. So it is likely that the error is in var file = await _cacheManager.getFileFromCache(url); as the future never resolves. Moreover the problem is not reproduceable on any device as long as the debugger is attached. At this point I am not sure what to do anymore. Maybe you have any ideas?

sillydomnom avatar Sep 13 '22 15:09 sillydomnom

Also being affected by this unfortunately and haven't found a solution till now.

osharaki avatar Sep 13 '22 15:09 osharaki

Any solution for this issue? I am having the same problem.

TaehwanSong avatar Dec 13 '23 06:12 TaehwanSong