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

パッケージ詳細v3.0.1

optimized_cached_image

ネットワークから画像を読み込み、コンテナーサイズに応じてリサイズし、メモリ使用量に配慮したキャッシュを提供するライブラリです。

30日間ダウンロード
355
いいね数
114
Pub ポイント
60

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

flutter pub add optimized_cached_image

パッケージ概要

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

OptimizedCachedImage は、ネットワーク画像を効率的に読み込み、リサイズし、キャッシュするための Flutter パッケージです。メモリ使用量を最小限に抑えます。自動的にコンテナの寸法に合わせて画像サイズを調整することで、不要なメモリ消費を削減します。キャッシュ機構を活用し、リソース処理を最適化することで、スムーズなパフォーマンスを実現します。頻繁に画像を読み込むアプリに最適で、ユーザー体験を損なうことなく、スピードと効率のバランスを保ちます。

用途

  • URLからダイナミックな画像を読み込む
  • コンテナの寸法に合わせて画像をリサイズする
  • ネットワークリクエストを減らすために画像をキャッシュする
  • 画像が多く含まれるアプリでのメモリ使用量の削減
  • 効率的な画像処理によるアプリのパフォーマンス向上

主な機能

  • 自動画像リサイズ
  • メモリ効率の良いキャッシュ
  • ネットワーク画像の読み込み
  • コンテナ認識スケーリング
  • 低いメモリオーバーヘッド

適している対象

  • 高画像トラフィックのアプリ
  • パフォーマンスが重要なUI
  • メモリが限られたモバイルアプリ
  • 画像ギャラリーとフィード
  • ECサイトまたはソーシャルメディアアプリ

注意事項

  • 初期読み込みにはインターネット接続が必要です
  • カスタムキャッシュポリシーの設定が必要になる場合があります
  • 制限されたプラットフォーム固有の最適化
  • 静的ローカル画像には適していません
  • 外部ネットワークの信頼性に依存しています

元の README

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

Optimized Cached Image

pub package

❌❌ Important Update ❌❌

This library is no longer being maintained. When I started this library, it was meant to add memory performant extensions which could not be directly added into the parent library. Since then a lot has changed, the parent library has incorporated similar changes, perhaps with the exception of a trivial LayoutBuilder that auto detects image sizes. I feel like this is a good time to deprecate this library in favour of the parent.

Description

A flutter library for loading images from network, resizing and caching them for memory sensitivity. This resizes and stores the images in cache based on parent container constraints and hence loads images of lower size into memory. This is heavily inspired by cached_network_image library.

This library exposes two classes for loading images

  • OptimizedCacheImage which is a 1:1 mapping of CachedNetworkImage.
  • OptimizedCacheImageProvider which is a mapping of CachedNetworkImageProvider.

How to use

The OptimizedCacheImage can be used directly or through the ImageProvider. Both the OptimizedCacheImage as OptimizedCacheImageProvider have minimal support for web. It currently doesn't include caching.

With a placeholder:

OptimizedCacheImage(
        imageUrl: "http://via.placeholder.com/350x150",
        placeholder: (context, url) => CircularProgressIndicator(),
        errorWidget: (context, url, error) => Icon(Icons.error),
     ),

Or with a progress indicator:

OptimizedCacheImage(
       imageUrl: "http://via.placeholder.com/350x150",
       progressIndicatorBuilder: (context, url, downloadProgress) =>
               CircularProgressIndicator(value: downloadProgress.progress),
       errorWidget: (context, url, error) => Icon(Icons.error),
    ),
Image(image: OptimizedCacheImageProvider(url))

When you want to have both the placeholder functionality and want to get the imageprovider to use in another widget you can provide an imageBuilder:

OptimizedCacheImage(
  imageUrl: "http://via.placeholder.com/200x150",
  imageBuilder: (context, imageProvider) => Container(
    decoration: BoxDecoration(
      image: DecorationImage(
          image: imageProvider,
          fit: BoxFit.cover,
          colorFilter:
              ColorFilter.mode(Colors.red, BlendMode.colorBurn)),
    ),
  ),
  placeholder: (context, url) => CircularProgressIndicator(),
  errorWidget: (context, url, error) => Icon(Icons.error),
),

Handling Gifs

OCI uses Flutter Image Compress as the compression library, while being memory efficient this library doesn't provide out of box support for gifs, however it does allow compressing to webp. Hence all gifs are compressed to webp format beginning 2.0.2-alpha.

How it works

The optimized cached network images stores and retrieves files using the flutter_cache_manager.

FAQ

My app crashes when the image loading failed. (I know, this is not really a question.)

Does it really crash though? The debugger might pause, as the Dart VM doesn't recognize it as a caught exception; the console might print errors; even your crash reporting tool might report it (I know, that really sucks). However, does it really crash? Probably everything is just running fine. If you really get an app crashes you are fine to report an issue, but do that with a small example so we can reproduce that crash.

カテゴリー

依存関係

依存関係一覧 11 件

ソースリポジトリ

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

データはまだありません。