パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v4.13.2

cached_network_image_ce

ネットワーク画像の読み込みとキャッシュを行うコミュニティエディションのFlutterライブラリです。プレースホルダーやエラーウィジェットとも併用可能です。

AndroidiOSmacOSWindowsLinux
30日間ダウンロード
18.7万
いいね数
109
Pub ポイント
160

パッケージをインストール

flutter pub add cached_network_image_ce

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

ネットワーク画像の効率的な読み込みとキャッシュを実現するコミュニティエディションのFlutterパッケージです。読み込み中にはプレースホルダーをサポートし、画像の取得に失敗した場合にはエラー用ウィジェットも提供します。画像をローカルに保存することで、重複するネットワークリクエストを減らし、パフォーマンスを向上させるように設計されています。Android、iOS、macOS、Windows、Linuxなど、多数のプラットフォームに対応しています。ソーシャルメディアフィードや製品カタログなど、多数のリモート画像を表示するアプリに最適です。

用途

  • リストビュー内のURLから画像を読み込む
  • 画像が読み込まれる間にプレースホルダーを表示しています
  • 画像の読み込みに失敗した場合をスムーズに処理する
  • 帯域幅の使用量を減らすために画像をキャッシュする
  • ローカル画像ストレージによるアプリのパフォーマンス向上

主な機能

  • パフォーマンス向上のための画像キャッシュ
  • プレースホルダーやエラービジェットのサポート
  • クロスプラットフォーム互換性
  • 効率的なメモリ管理
  • カスタマイズ可能なオプションを備えたシンプルな API

適している対象

  • 頻繁に画像を読み込むアプリ
  • ソーシャルメディアまたは電子商取引アプリケーション
  • 軽量な画像キャッシュを求める開発者
  • 信頼できるフォールバックUIを必要とするプロジェクト
  • コミュニティメンテナンスパッケージを使用するチーム

注意事項

  • モバイルプラットフォームではインターネット権限が必要です
  • 時間が経つにつれてデバイスのストレージを消費する可能性があります
  • 基本的な使用ではキャッシュサイズを設定できません
  • 限定された高度なキャッシュ制御機能
  • 更新には外部リポジトリに依存しています

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

cached_network_image_ce banner

pub package Listed on Flutter Gems CI status License: MIT GitHub stars GitHub Sponsors

Powered by hive_ce 8x faster cache reads Platform support

Zero-jank image caching for Flutter

cached_network_image_ce is the actively maintained fork of cached_network_image, rebuilt around a caching engine that doesn't block your UI thread. Same widget and provider API you already use.


Table of contents

Why this fork exists

cached_network_image by Baseflow is one of the most widely used packages in the Flutter ecosystem. It has also been effectively unmaintained since August 2024, sitting on 300+ open issues, including memory leaks and scroll-performance bugs that never got fixed.

Under the hood it leans on sqflite for cache metadata: a full SQL engine routed through a platform channel just to answer "have I already downloaded this image?" On image-heavy lists, that overhead shows up as jank you can feel.

We didn't fork this just to merge dependabot PRs. We rebuilt the caching layer.

We swapped sqflite for hive_ce, a pure-Dart, non-blocking key-value store. It skips the platform channel round trip and the SQL parser entirely, so there's no jank left to fix.

How we stack up

vs. the original cached_network_image:

Original (cached_network_image) This fork (cached_network_image_ce)
Cache backend sqflite (platform channel) ✅ hive_ce (pure Dart)
Maintenance ❌ stale since Aug 2024 ✅ active, regular releases
Web caching ⚠️ browser cache only ✅ full persistent IndexedDB cache
HTTP / cache interceptors ❌ ✅ full chains (auth, logging, custom responses)
Cache eviction ❌ fixed ✅ pluggable — TTL or LRU
Cache read (10 KB) 16 ms ✅ 2 ms — 8x faster
Unsupported formats (SVG/AVIF/HEIC) ❌ opaque decode error ✅ unsupportedImageBuilder hook

vs. other popular alternatives, checked live against pub.dev, so this is current rather than a guess:

Package Cache backend Web support Interceptors Cleanup strategy Maintenance
cached_network_image_ce (this) hive_ce ✅ full IndexedDB ✅ HTTP + cache ✅ TTL / LRU ✅ active
cached_network_image sqflite ⚠️ browser only ❌ ❌ fixed ❌ stale
flutter_cache_manager sqflite / plain JSON ✅ ❌ ❌ fixed ✅ active
extended_image undisclosed ✅ ⚠️ headers/retry only ⚠️ manual clear ✅ active
fast_cached_network_image hive (plain) ✅ (claimed) ❌ ⚠️ TTL only ⚠️ stale (17mo)

Worth saying plainly: flutter_cache_manager and extended_image are both actively maintained by reputable teams. They're solving different problems than we are: a generic file cache, and a broad image/gesture toolkit, respectively. The "actively maintained fork" pitch applies specifically against the original cached_network_image, which this package is a drop-in replacement for.

Architecture

flowchart LR
    W[CachedNetworkImage widget] --> P[CachedNetworkImageProvider]
    P --> M[DefaultCacheManager]
    M --> H[("Hive CE<br/>metadata: URL, path,<br/>validTill, eTag")]
    M --> FS[("Native filesystem<br/>raw image bytes")]
    H -.cache hit.-> P
    FS -.cache hit.-> P

    subgraph Original[Original package, for comparison]
        direction LR
        W2[CachedNetworkImage] --> M2[CacheManager]
        M2 --> PC[Platform Channel]
        PC --> SQL[(SQLite via sqflite)]
    end
  • Old way: Dart → platform channel → native SQLite → disk. Slow, blocking.
  • New way: Dart → Hive CE (pure Dart, non-blocking) → disk. Instant.

That difference is what gets you zero-jank scrolling, even in image-dense lists.

🚀 Benchmarks

Measured cache metadata operations (check, write, delete) on an iPhone Simulator:

Operation Payload Original (sqflite) CE (hive_ce) Improvement
Read (Hit Check) 10 KB 16 ms 2 ms 8.00x faster
Write (New Image) 10 KB 116 ms 29 ms 4.00x faster
Delete (Cleanup) 10 KB 55 ms 19 ms 2.89x faster
Read (Large) 1 MB 8 ms 1 ms 8.00x faster

"Read" matters most for scroll performance, since every list item checks the cache before rendering.

Benchmark results on iPhone Simulator

Used by

Real apps shipping with cached_network_image_ce, found via a live GitHub code search for pubspec.yaml files that depend on it, sorted by stars:

Project Stars What it is
Kazumi stars Rule-based anime scraper and streaming app with danmaku and real-time super-resolution.
PiliPlus stars Third-party Bilibili client built with Flutter.
plezy stars Cross-platform Plex and Jellyfin client.
conduit stars Native iOS/Android client for Open WebUI, OpenAI-compatible APIs, Ollama, and OpenRouter.
haka_comic stars Third-party, ad-free client for the PicACG (Bika/Pica) comics platform.
MusicPod stars Music, radio, TV, and podcast player for Ubuntu and macOS.
Fluxer stars Official mobile client for Fluxer.
jd_mall_flutter stars Flutter clone of a major Chinese e-commerce marketplace app.
BoxBox stars Unofficial Formula 1 and Formula E companion app.

Shipping something with it? Open a PR and add yours, or check the full, current list yourself.

Features

  • Drop-in replacement — 99% API compatible with the original package.
  • hive_ce powered — instant, non-blocking cache lookups.
  • Real web support — persistent IndexedDB caching, not just browser HTTP cache.
  • HTTP & cache interceptors — inject auth headers, logging, or synthetic responses without forking anything.
  • Pluggable eviction — TTL (default) or LRU cleanup strategies.
  • Pre-caching API — CachedNetworkImage.preCache() downloads and caches images before they hit the screen, for instant navigation.
  • Graceful unsupported-format handling — SVG/AVIF/HEIC decode failures route to unsupportedImageBuilder instead of a bare exception.
  • Actively maintained — regular releases, community-driven roadmap.

Quick start

flutter pub add cached_network_image_ce
import 'package:cached_network_image_ce/cached_network_image.dart';

CachedNetworkImage(
  imageUrl: 'https://example.com/image.jpg',
  placeholder: (context, url) => const CircularProgressIndicator(),
  errorWidget: (context, url, error) => const Icon(Icons.error),
)

Full docs and advanced usage

The quick start above covers the basics. For interceptors, cleanup strategies, connection timeouts, custom cache and metadata directories, web render modes, and unsupported-format handling, see the full reference:

cached_network_image/README.md

FAQ

Q: Will I lose my users' existing cache if I migrate? A: Yes. Because we switched the storage engine from SQLite to Hive, the old cache files will be ignored. Users will re-download images once as they browse. This is a one-time migration cost for a permanent performance gain.

Q: My app crashes/pauses on errors? A: In Debug mode, Flutter may pause on exceptions even if they are caught. This is expected behavior for network errors (404s). In Release mode, these are handled silently by the errorWidget.

Q: Why is web caching slower, or why does it use Hive for image bytes? A: On Mobile & Desktop (IO), this package stores image bytes directly on the native file system and uses Hive only for metadata. Web lacks a native file system, so hive_ce stores both metadata and image bytes in IndexedDB there. Serializing large byte arrays in and out of IndexedDB carries overhead that doesn't exist on IO. Alternative: if persistent caching across sessions isn't critical for your web users, consider conditionally using Image.network on web, which relies on the browser's built-in caching.

Contributing

We welcome contributions! If you want to help maintain this package, check CONTRIBUTING.md.

License

MIT. See LICENSE for details.

カテゴリー

依存関係

依存関係一覧 11 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

ランキング