Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Error when used with cached_network_image by setting up the cacheManager

Open
#410 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
dart, flutter
Domain
mobile-dev

Research direction

Reproduce the issue with cached_network_image 3.2.3 and flutter_cache_manager 3.3.0 using a CacheManager configured with a two-hour stalePeriod, then capture the complete error and stack trace. Trace the cache cleanup operation that reports “No such file or directory” on Android and iOS; done means the reproduced scenario completes without an unhandled error.

Written by the indexing model from the issue text.

Description

🐛 Bug Report

I am experiencing an issue while using the flutter_cache_manager package along with the cached_network_image package in my Flutter project. I have set the cacheManager property and set the stalePeriod to 2 hours for my cache configuration. When I run my project in development mode after 1 or 2 days, an error occurs which stops the app process. The error message will be in screenshots. But the ending is: "OS Error: No such file or directory, errno = 2".

It seems like the app is trying to delete a non-existing cache file.

Expected behavior

The app should run without any issues, and the cache should be managed appropriately.

Actual behavior

The app "crashes" (in development mode) with the error message "OS Error: No such file or directory, errno = 2".

Reproduction steps
  1. Set up a project using the cached_network_image and flutter_cache_manager packages.
  2. Configure the stalePeriod to be short (my case was 2 hours).
  3. Run the project in development mode.
  4. Close the app.
  5. Wait for more than the statePeriod. In my case around 1 or 2 days.
  6. Run the project again in development mode.
Configuration

Flutter version: It was 3.5.x or 3.6.x. Now I use 3.7.11
cached_network_image package version: 3.2.3
flutter_cache_manager package version: 3.3.0
Device/Emulator: Android emulator on Windows & iOS emulator on Mac
OS: Windows 11 & MacOS

Additional Context

Here is the code snippet where I configure the cache manager and use the CachedNetworkImage widget:

  Widget _buildPhoto(bool useDarkMode) {
    return CachedNetworkImage(
      imageUrl: photoUrl,
      height: height,
      alignment: const Alignment(-1.0, -1.0),
      cacheManager: CacheManager(
        Config(
          'photoCache',
          stalePeriod: const Duration(hours: 2),
        ),
      ),
      fadeInDuration: Duration.zero,
      fadeOutDuration: Duration.zero,
      placeholder: (context, url) => Container(
        color: useDarkMode ? DarkColors.lightColor : LightColors.lightColor,
      ),
      errorWidget: (
        BuildContext context,
        String url,
        dynamic error,
      ) {
        return Container(
          width: double.infinity,
          height: height,
          color: useDarkMode ? DarkColors.lightColor : LightColors.lightColor,
        );
      },
    );
  }
}

Platform:

  • 📱 iOS

image
image
image

Dominant language
Dart
Stars
810
Forks
510
Avg merge
2d 2h
Merged PRs (30d)
11

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Baseflow/flutter_cache_manager

All issues in Baseflow/flutter_cache_manager

Similar issues

More Dart issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.