firestore_db_impl 0.0.2+1 copy "firestore_db_impl: ^0.0.2+1" to clipboard
firestore_db_impl: ^0.0.2+1 copied to clipboard

A Flutter package that simplifies Firestore operations by providing structured CRUD methods, query abstraction, custom exceptions, and utility services for timestamps and counters.

firestore_db_impl #

firestore_db_impl is a Flutter package that provides an implementation layer over Firebase Cloud Firestore for easier and more consistent CRUD operations, querying, and error handling. It aims to reduce boilerplate and standardize interactions with Firestore, allowing developers to focus more on business logic.

Features #

  • Simplified Firestore CRUD operations
  • Stream and Future-based data retrieval
  • Structured exception handling
  • Query parameter abstraction with enums
  • Firestore timestamp and counter utilities
  • Extensible and modular architecture

Getting Started #

Installation #

Add the following to your pubspec.yaml:

dependencies:
  firestore_db_impl: <latest_version>

Import #

import 'package:firestore_db_impl/firestore_db_impl.dart';

Usage #

Save a Document #

final service = FireStoreDbCrudServiceImpl();
String? docId = await service.saveDocument(
  data: {'name': 'John Doe'},
  collectionPath: 'users',
);

Update a Document #

await service.updateDocument(
  collectionPath: 'users',
  id: docId,
  data: {'name': 'Jane Doe'},
);

Query Documents #

final queryParams = [
  QueryParameter(type: QueryType.where, field: 'role', value: 'admin'),
];
List<Map<String, dynamic>?>? results = await service.getAllDocuments(
  collectionPath: 'users',
  queryParameters: queryParams,
);

Stream Documents #

Stream<List<Map<String, dynamic>?>?> userStream = service.getStreamAllDocuments(
  collectionPath: 'users',
);

Get a Document by ID #

Map<String, dynamic>? user = await service.getDocumentById(
  collectionPath: 'users',
  id: docId,
);

Extensions #

  • QueryExtension: Apply QueryParameter to Firestore queries
  • DocumentSnapshotExtension: Convert Firestore snapshots to maps or models
  • QuerySnapshotExtension: Convert query results to a list or map

Error Handling #

This package provides a robust error-handling system through custom exceptions:

  • NoInternetConnectionException
  • UnauthorizedException
  • BadResponseFormatException
  • FireStoreException, and more

Utility Services #

  • FireStoreIteratorServiceImpl: Increment/Decrement field values
  • FireStoreTimerServiceImpl: Server timestamp handling

Dependencies #

  • cloud_firestore
  • flutter

License #

MIT License

0
likes
80
points
163
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter package that simplifies Firestore operations by providing structured CRUD methods, query abstraction, custom exceptions, and utility services for timestamps and counters.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

app_toast, cloud_firestore, fire_storage_impl, firebase_auth, firebase_database, flutter, fluttertoast, get_it_di_global_variable, language_translator, navigation_wihout_context

More

Packages that depend on firestore_db_impl