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

パッケージ詳細v2.21.7

firestore_cache

キャッシュから最初に読み取り、次にサーバーからFirestoreドキュメントを取得するためのFlutterプラグイン

AndroidiOSWebmacOSWindows
30日間ダウンロード
3340
いいね数
107
Pub ポイント
160

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

flutter pub add firestore_cache

パッケージ概要

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

firestore_cache は、Firestore のドキュメントをキャッシュから優先して取得する戦略を実装する Flutter パッケージです。これにより、高速なローカル応答を保証しつつ、サーバーとの同期もオプションで行えます。キャッシュデータを即時表示に優先し、サーバーから非同期でキャッシュを更新することで、ネットワーク遅延やオフライン状態でもアプリのパフォーマンスとユーザー体験が向上します。このパッケージは Android、iOS、Web、macOS、Windows などすべての主要プラットフォームをサポートしており、応答性の高いデータアクセスとフォールバックの信頼性を必要とするアプリケーションに最適です。

用途

  • オフライン優先のデータ取得
  • 高速な初期UIレンダリング
  • Firestore とのバックグラウンド同期
  • 改善されたアプリの応答性
  • シームレスなネットワーク回復

主な機能

  • キャッシュ優先のドキュメント取得
  • 自動サーバー同期
  • クロスプラットフォーム対応
  • シンプルなAPI統合
  • リアルタイムデータの一貫性

適している対象

  • 高速なローカルデータアクセスを必要とするアプリ
  • オフライン機能を実装する開発者
  • Firebase Firestore を使用するプロジェクト
  • 即時のフィードバックを必要とするUI
  • 信頼できないネットワーク接続を持つアプリケーション

注意事項

  • 初期は古くなったデータを提供する可能性があります
  • キャッシュ無効化の注意深い取り扱いが必要です
  • リアルタイムの重要な更新には適していません
  • Firestore ドキュメントの読み取りに制限
  • ネットワーク使用量は同期頻度に依存します

元の README

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

Firestore Cache

pub package docs MIT License GitHub Actions codecov Codacy Badge style: flutter_lints

Github-sponsors BuyMeACoffee Ko-Fi LiberaPay Patreon PayPal

A Flutter plugin for fetching Firestore documents with read from cache first then server.

This plugin is mainly designed for applications using the DocumentReference.get() and Query.get() methods in the cloud_firestore plugin, and is implemented with read from cache first then server.

Getting Started

Add this to your package's pubspec.yaml file:

dependencies:
  firestore_cache: ^2.21.2
Usage

Before using the plugin, you will need to create a document on Firestore and create a timestamp field in that document. See the screenshot below for an example:

Firestore Screenshot

⚠️ PLEASE NOTE This plugin does not compare the documents in the cache and the ones in the server to determine if it should fetch data from the server. Instead, it relies on the timestamp field in the document to make that decision. And so your application should implement the logic to update this field if you want to read new data from the server instead of reading it from the cache.

You should also create different timestamp fields for different collections or documents that you are fetching.

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firestore_cache/firestore_cache.dart';

// This should be the path of the document containing the timestamp field
// that you created
final cacheDocRef = Firestore.instance.doc('status/status');

// This should be the timestamp field in that document
final cacheField = 'updatedAt';

final query = Firestore.instance.collection('posts');
final snapshot = await FirestoreCache.getDocuments(
    query: query,
    cacheDocRef: cacheDocRef,
    firestoreCacheField: cacheField,
);

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

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

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