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

パッケージ詳細v1.1.1

firebase_image

Firebase Cloud Storage の画像オブジェクト用のキャッシュされた Flutter ImageProvider。

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

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

flutter pub add firebase_image

パッケージ概要

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

Firebase Cloud Storage に格納された画像用のキャッシュ付き ImageProvider を提供する Flutter パッケージです。キャッシュ、エラー状態、ローディングインジケーターを自動的に処理することで、リモート画像の読み込みと表示を簡素化します。Firebase のストレージシステムとスムーズに連携できるように設計されており、ボイラープレートコードを減らし、重複ダウンロードを回避することでパフォーマンスを向上させます。軽量で、複雑なセットアップなしに既存の Flutter アプリに直接統合できます。

用途

  • Firebase Cloud Storage から画像を読み込む
  • パフォーマンス向上のためリモート画像をキャッシュする
  • プレースホルダーやエラー画像を表示しています
  • Flutter の Image ウィジェットとの統合
  • キャッシュによるネットワークリクエストの削減

主な機能

  • 自動画像キャッシュ
  • 読み込み、エラー、プレースホルダー状態のサポート
  • Firebase Cloud Storage とのシームレスな統合
  • 最小限のボイラープレートが必要
  • 効率的なメモリおよびディスク使用

適している対象

  • 画像に Firebase Cloud Storage を使用するアプリ
  • 簡単な画像読み込みを求める開発者
  • オフライン画像アクセスを必要とするプロジェクト
  • 高頻度画像表示アプリ
  • パフォーマンスと信頼性を重視するチーム

注意事項

  • Firebase Cloud Storage の設定が必要です
  • Firebaseホスト画像に限定
  • 組み込みの画像変換なし
  • すべての画像形式をサポートしていません
  • Firebase SDK の利用可能性に依存します

元の README

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

🔥 Firebase Image Provider

pub package

A cached Flutter ImageProvider for Firebase Cloud Storage image objects.

How to use

Make sure you already have Firebase set up on all platforms you want to use this on.

Supply the FirebaseImage widget with the image's URI (e.g. gs://bucket123/userIcon123.jpg) and then put that in any widget that accepts an ImageProvider (most image related widgets will (e.g. Image, ImageIcon, etc.)). Please note that you do need the gs:// prefix currently.

See the below for example code.

How does it work?

The code downloads the image (object) into memory as a byte array.

Unless disabled using the cacheRefreshStrategy: CacheRefreshStrategy.NEVER option, it gets the object's last update time from metadata (a millisecond precision integer timstamp) and uses that as a defacto version number. Therefore, any update to that remote object will result in the new version being downloaded.

The image byte array in memory then gets saved to a file in the temporary directory of the app and that location is saved in a persistant database. The OS can clean up this directory at any time however.

Metadata retrival is a 'Class B Operation' and has 50,000 free operations per month. After that, it is billed at $0.04 / 100,000 operations and so the default behaviour of cacheRefreshStrategy: CacheRefreshStrategy.BY_METADATA_DATE may incur extra cost if the object never changes. This makes this implementation a cost effective stratergy for caching as the entire object doesn't have to be transfered just to check if there have been any updates. Essentailly, any images will only need to be downloaded once per device.

Example

import 'package:flutter/material.dart';
import 'package:firebase_image/firebase_image.dart';

class IconImage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Firebase Image Provider example'),
      ),
      body: Image(
        image: FirebaseImage('gs://bucket123/userIcon123.jpg'),
        // Works with standard parameters, e.g.
        fit: BoxFit.fitWidth,
        width: 100,
        // ... etc.
      ),
    );
  }
}

To Do

  • [x] Add examples to pub.dev
  • [ ] Clear items from cache if they haven't been accessed after a certain amount of time (2 weeks?)
  • [ ] Add more documentation/comments
  • [ ] Create unit tests

Contributing

If you want to contribute, please fork the project and play around there!

If you're stuck for ideas, check Issues or the above To Do list for inspiration.

Please check PRs and other peoples forks to see if anyone is working on something similiar to what you want to do.

Once you're ready, please submit a pull request.

カテゴリー

依存関係

依存関係一覧 5 件

ソースリポジトリ

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

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