Skip to content
pubscout

fake_cloud_firestore

4.5.0, released 4 weeks ago by wafrat.com

Fake implementation of Cloud Firestore for unit testing.

Rock solid
$ flutter pub add fake_cloud_firestore
Source repository

What it does

Provides a mock version of Cloud Firestore that keeps data in memory. Enables testing of apps using Cloud Firestore without needing a live backend connection or emulator.

AI-written summary of version 4.5.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want to write unit or widget tests for apps that use Cloud Firestore.
  • You need an in-memory database to quickly test queries, snapshots, and document updates.

Skip it when

  • You are running integration tests that require actual backend connectivity or Firebase Emulators.
  • You need to test features of Cloud Firestore that are not yet implemented by the fake library.

Strengths

  • Runs entirely in memory for fast unit testing.
  • Supports complex queries, transactions, batch writes, and custom security rules.

Weaknesses

  • Does not support all Cloud Firestore features (e.g., timestamps and durations in security rules are limited).
  • Requires maintaining compatibility versions matching the `cloud_firestore` package.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
10

not documented

import 'package:fake_cloud_firestore/fake_cloud_firestore.dart';

void main() async {
  final instance = FakeFirebaseFirestore();
  await instance.collection('users').add({
    'username': 'Bob',
  });
  final snapshot = await instance.collection('users').get();
  print(snapshot.docs.length); // 1
}

Alternatives

Packages that do the same job and could replace fake_cloud_firestore.

Works with

Packages commonly used together with fake_cloud_firestore: ones it builds on, ones built on it, and its own family.