cloud_firestore 0.2.9

  • Example
  • Installing
  • Versions
  • 94

Cloud Firestore Plugin for Flutter

A Flutter plugin to use the Cloud Firestore API.

pub package

For Flutter plugins for other Firebase products, see

Note: This plugin is still under development, and some APIs might not be available yet. Feedback and Pull Requests are most welcome!


To use this plugin:

  1. Using the Firebase Console, add an Android app to your project: Follow the assistant, download the generated google-services.json file and place it inside android/app. Next, modify the android/build.gradle file and the android/app/build.gradle file to add the Google services plugin as described by the Firebase assistant. Ensure that your android/build.gradle file contains the as described here.
  2. Using the Firebase Console, add an iOS app to your project: Follow the assistant, download the generated GoogleService-Info.plist file, open ios/Runner.xcworkspace with Xcode, and within Xcode place the file inside ios/Runner. Don't follow the steps named "Add Firebase SDK" and "Add initialization code" in the Firebase assistant.
  3. Add cloud_firestore as a dependency in your pubspec.yaml file.


import 'package:cloud_firestore/cloud_firestore.dart';

Adding a new DocumentReference:

  .setData({ 'title': 'title', 'author': 'author' });

Binding a CollectionReference to a ListView:

class BookList extends StatelessWidget {
  Widget build(BuildContext context) {
    return new StreamBuilder(
      stream: Firestore.instance.collection('books').snapshots,
      builder: (context, snapshot) {
        if (!snapshot.hasData) return new Text('Loading...');
        return new ListView(
          children: {
            return new ListTile(
              title: new Text(document['title']),
              subtitle: new Text(document['author']),

Getting Started

See the example directory for a complete sample app using Cloud Firestore.


  • Relax sdk upper bound constraint to '<2.0.0' to allow 'edge' dart sdk use.


  • Support for Query.getDocuments


  • Add transaction support.


  • Build fixes for iOS
  • Null checking in newly added Query methods


  • Query can now have more than one orderBy field.
  • startAt, startAfter, endAt, and endBefore support
  • limit support


  • Support for DocumentReference.documentID
  • Support for CollectionReference.add


  • Simplified and upgraded Android project template to Android SDK 27.
  • Updated package description.


  • Add get to DocumentReference.


  • Fix bug on Android where removeListener is sometimes called without a handle


  • Breaking change. Upgraded to Gradle 4.1 and Android Studio Gradle plugin 3.0.1. Older Flutter projects need to upgrade their Gradle setup as well in order to use this version of the plugin. Instructions can be found here.
  • Relaxed GMS dependency to [11.4.0,12.0[


  • Support for DocumentReference update and merge writes
  • Suppress unchecked warnings and package name warnings on Android


  • Added FLT prefix to iOS types.


  • Added reference to DocumentSnapshot
  • Breaking: removed path from DocumentSnapshot
  • Additional test coverage for reading collections and documents
  • Fixed typo in DocumentChange documentation


  • Support for getCollection


  • Support isNull filtering in Query.where
  • Fixed DocumentChange.oldIndex and DocumentChange.newIndex to be signed integers (iOS)


  • Support for where clauses
  • Support for deletion


  • Renamed package to cloud_firestore


  • Add path property to DocumentSnapshot


  • Update project homepage


  • Initial Release


// Copyright 2017, the Chromium project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:async';

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

void main() {
  runApp(new MaterialApp(title: 'Firestore Example', home: new MyHomePage()));

class BookList extends StatelessWidget {
  Widget build(BuildContext context) {
    return new StreamBuilder<QuerySnapshot>(
      stream: Firestore.instance.collection('books').snapshots,
      builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
        if (!snapshot.hasData) return const Text('Loading...');
        return new ListView(
          children: document) {
            return new ListTile(
              title: new Text(document['message']),

class MyHomePage extends StatelessWidget {
  CollectionReference get messages => Firestore.instance.collection('messages');

  Future<Null> _addMessage() async {
        .setData(<String, String>{'message': 'Hello world!'});

  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: const Text('Firestore Example'),
      body: new BookList(),
      floatingActionButton: new FloatingActionButton(
        onPressed: _addMessage,
        tooltip: 'Increment',
        child: new Icon(Icons.add),

1. Depend on it

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

  cloud_firestore: "^0.2.9"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:cloud_firestore/cloud_firestore.dart';
Version Uploaded Documentation Archive
0.2.9 Feb 15, 2018 Go to the documentation of cloud_firestore 0.2.9 Download cloud_firestore 0.2.9 archive
0.2.8 Feb 2, 2018 Go to the documentation of cloud_firestore 0.2.8 Download cloud_firestore 0.2.8 archive
0.2.7 Feb 1, 2018 Go to the documentation of cloud_firestore 0.2.7 Download cloud_firestore 0.2.7 archive
0.2.6 Jan 20, 2018 Go to the documentation of cloud_firestore 0.2.6 Download cloud_firestore 0.2.6 archive
0.2.5 Jan 20, 2018 Go to the documentation of cloud_firestore 0.2.5 Download cloud_firestore 0.2.5 archive
0.2.4 Jan 13, 2018 Go to the documentation of cloud_firestore 0.2.4 Download cloud_firestore 0.2.4 archive
0.2.3 Jan 12, 2018 Go to the documentation of cloud_firestore 0.2.3 Download cloud_firestore 0.2.3 archive
0.2.2 Jan 5, 2018 Go to the documentation of cloud_firestore 0.2.2 Download cloud_firestore 0.2.2 archive
0.2.1 Jan 3, 2018 Go to the documentation of cloud_firestore 0.2.1 Download cloud_firestore 0.2.1 archive
0.2.0 Dec 20, 2017 Go to the documentation of cloud_firestore 0.2.0 Download cloud_firestore 0.2.0 archive

All 17 versions...


This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • tool failures on Feb 15, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1
  • Flutter: 0.0.22


Describes how popular the package is relative to other packages. [more]
97 / 100
Code health derived from static analysis. [more]
100 / 100
Reflects how tidy and up-to-date the package is. [more]
76 / 100
Overall score:
Weighted score of the above. [more]


Detected platforms: unsure

Error(s) prevent platform classification.


  • Fix dependencies in pubspec.yaml.

    Running flutter packages pub upgrade failed with the following output:

    ERR: Invalid argument(s): Minimum version ("2.0.0-dev.23.0") must be less than maximum ("2.0.0-dev.16.0").
    ERR: package:pub_semver/src/version_range.dart 59         new VersionRange
     package:pub/src/pubspec.dart 366                     Pubspec._ensureEnvironment
     package:pub/src/pubspec.dart 331                     Pubspec.dartSdkConstraint
     package:pub/src/solver/backtracking_solver.dart 511  BacktrackingSolver._checkPubspecMatchesSdkConstraint
     package:pub/src/solver/backtracking_solver.dart 474  BacktrackingSolver._checkVersion
     ===== asynchronous gap ===========================
     package:pub/src/solver/backtracking_solver.dart 432  BacktrackingSolver._findValidVersion.<fn>
     ===== asynchronous gap ===========================
     dart:async                                           Future.doWhile
     package:pub/src/solver/backtracking_solver.dart 430  BacktrackingSolver._findValidVersion
     package:pub/src/solver/backtracking_solver.dart 337  BacktrackingSolver._versionQueueFor
     ===== asynchronous gap ===========================
     package:pub/src/solver/backtracking_solver.dart 290  BacktrackingSolver._solve.<fn>
     ===== asynchronous gap ===========================
     dart:async                                           _completeOnAsyncReturn
     package:pub/src/solver/backtracking_solver.dart 315  BacktrackingSolver._solve.<fn>
     dart:async                                           _completeOnAsyncReturn
     package:pub/src/solver/version_selection.dart 64
     dart:async                                           _completeOnAsyncReturn
     package:pub/src/solver/version_selection.dart 91     VersionSelection._addDependencies
     dart:async                                           _completeOnAsyncReturn
     package:pub/src/solver/version_selection.dart 91     VersionSelection._addDependencies
    ERR: This is an unexpected error. Please run
         pub --trace upgrade --verbosity io --no-precompile
     and include the logs in an issue on
  • Fix platform conflicts.

    Make sure none of the libraries use mutually exclusive dependendencies.

  • Fix issues reported by dartanalyzer.

    dartanalyzer reported 1 error(s) and 0 warning(s).

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0