firebase_service 0.0.1+1 copy "firebase_service: ^0.0.1+1" to clipboard
firebase_service: ^0.0.1+1 copied to clipboard

A collection of packages, created to increase code reuse across many of my Flutter projects.

This package includes FirestoreService, a wrapper class for the cloud_firestore APIs.

FirestoreService uses generics and the builder pattern to provide a type-based abstraction on top of cloud_firestore.

It covers only a very limited subset of APIs from cloud_firestore.

Getting started #

In your flutter project add the dependency:

dependencies:
  firebase_service: ^<version>

Import package:

import 'package:firebase_service/firebase_service.dart';

Usage #

Create instance:

final service = FirestoreService.instance;

To write a document:

    final path = 'collection/$id';
    await service.set(path: path, data: {'id': id});

To update a document:

    final path = 'collection/$id';
    await service.update(path: path, data: {'id': id});

To delete a document:

    final path = 'collection/$id';
    await service.delete(path: path);

To get a document:

    final path = 'collection/$id';
    final res = await service.getDocument(
      path: path,
      builder: ((data, documentID) => data!),
    );

To stream a document:

    final path = 'collection/$id';
    final res = service.documentStream(
      path: path,
      builder: ((data, documentID) => data!),
    );

To stream a collection:

    final path = 'collection/$id';
    final res = service.collectionStream(
      path: path,
      builder: ((data, documentID) => data!),
    );

To get a collection:

    final path = 'collection/$id';
    final res = await service.getCollection(
      path: path,
      builder: ((data, documentID) => data!),
    );

To get a collection with limit:

    final path = 'collection/$id';
    final res = service.collectionStream(
      path: path,
      builder: ((data, documentID) => data!),
      limit: 20, //* <--- Just add a limit.
    );
0
likes
140
pub points
81%
popularity

Publisher

unverified uploader

A collection of packages, created to increase code reuse across many of my Flutter projects.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

cloud_firestore, firebase_core, flutter

More

Packages that depend on firebase_service