cloud_firestore 0.0.6

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 50

Cloud Firestore Plugin for Flutter #

A Flutter plugin to use the Cloud Firestore API.

For Flutter plugins for other Firebase products, see FlutterFire.md.

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 maven.google.com 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:

Firestore.instance.collection('books').document()
  .setData({ 'title': 'title', 'author': 'author' });

Binding a CollectionReference to a ListView:

class BookList extends StatelessWidget {
  @override
  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: snapshot.data.documents.map((document) {
            return new ListTile(
              title: new Text(document['title']),
              subtitle: new Text(document['author']),
            );
          }).toList(),
        );
      },
    );
  }
}

Getting Started #

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

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

example/lib/main.dart

// 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 {
  @override
  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: snapshot.data.documents.map((DocumentSnapshot document) {
            return new ListTile(
              title: new Text(document['message']),
            );
          }).toList(),
        );
      },
    );
  }
}

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

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

  @override
  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:


dependencies:
  cloud_firestore: ^0.0.6

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';
  
Version Uploaded Documentation Archive
0.11.0+2 May 14, 2019 Go to the documentation of cloud_firestore 0.11.0+2 Download cloud_firestore 0.11.0+2 archive
0.11.0+1 May 7, 2019 Go to the documentation of cloud_firestore 0.11.0+1 Download cloud_firestore 0.11.0+1 archive
0.11.0 May 7, 2019 Go to the documentation of cloud_firestore 0.11.0 Download cloud_firestore 0.11.0 archive
0.10.1 May 1, 2019 Go to the documentation of cloud_firestore 0.10.1 Download cloud_firestore 0.10.1 archive
0.10.0 Apr 29, 2019 Go to the documentation of cloud_firestore 0.10.0 Download cloud_firestore 0.10.0 archive
0.9.13+1 Apr 10, 2019 Go to the documentation of cloud_firestore 0.9.13+1 Download cloud_firestore 0.9.13+1 archive
0.9.13 Apr 8, 2019 Go to the documentation of cloud_firestore 0.9.13 Download cloud_firestore 0.9.13 archive
0.9.11 Apr 4, 2019 Go to the documentation of cloud_firestore 0.9.11 Download cloud_firestore 0.9.11 archive
0.9.10 Apr 3, 2019 Go to the documentation of cloud_firestore 0.9.10 Download cloud_firestore 0.9.10 archive
0.9.9 Apr 3, 2019 Go to the documentation of cloud_firestore 0.9.9 Download cloud_firestore 0.9.9 archive

All 66 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
100
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
50
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 https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

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

Dependencies were not resolved.

Dependencies

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