FirestoreCache class

FirestoreCache is a Flutter plugin for fetching Firestore documents with read from cache first then server.

Before using this plugin, you will need to do some inital setup on Firestore. Then you can use this sample code to fetch documents:

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

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

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

Constructors

FirestoreCache()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

getDocument(DocumentReference docRef, {Source source = Source.cache, bool isRefreshEmptyCache = true}) Future<DocumentSnapshot>
Fetch a document with read from cache first then server.
getDocuments({required Query query, required DocumentReference cacheDocRef, required String firestoreCacheField, String? localCacheKey, bool isUpdateCacheDate = true}) Future<QuerySnapshot>
Fetch documents with read read from cache first then server.
isFetchDocuments(DocumentReference cacheDocRef, String firestoreCacheField, String localCacheKey) Future<bool>