cloud_firestore 0.2.2

Cloud Firestore Plugin for Flutter #

A Flutter plugin to use the Cloud Firestore API.

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!

Setup #

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.

Usage #

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.

0.2.2 #

  • Add get to DocumentReference.

0.2.1 #

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

0.2.0 #

  • 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[

0.1.2 #

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

0.1.1 #

  • Added FLT prefix to iOS types.

0.1.0 #

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

0.0.6 #

  • Support for getCollection

0.0.5 #

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

0.0.4 #

  • Support for where clauses
  • Support for deletion

0.0.3 #

  • Renamed package to cloud_firestore

0.0.2 #

  • Add path property to DocumentSnapshot

0.0.1+1 #

  • Update project homepage

0.0.1 #

  • 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),

Use this package as a library

1. Depend on it

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

  cloud_firestore: ^0.2.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub 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';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0 <2.0.0-dev.infinity