firestore_fakes 1.0.1-alpha copy "firestore_fakes: ^1.0.1-alpha" to clipboard
firestore_fakes: ^1.0.1-alpha copied to clipboard

A Firestore fake library that gives you control over the data

example/lib/main.dart

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

void main() {
  runApp(MyHomePage(firestore: FirebaseFirestoreFake.stateful()));
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({required this.firestore, super.key});

  final FirebaseFirestore firestore;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) => MaterialApp(
        home: StreamBuilder(
          stream: widget.firestore
              .collection('books')
              .where('category', isEqualTo: 'philosophy')
              .snapshots(),
          builder: (context, snapshot) => Scaffold(
            appBar: AppBar(
              title: const Text('Books'),
            ),
            body: snapshot.data != null
                ? ListView(
                    children: snapshot.data!.docs
                        .map(
                          (documentSnapshot) => ListTile(
                            title: Text(documentSnapshot['title'] as String),
                          ),
                        )
                        .toList(),
                  )
                : const CircularProgressIndicator.adaptive(),
            floatingActionButton: FloatingActionButton(
              onPressed: () async =>
                  widget.firestore.collection('books').add(<String, dynamic>{
                'title': 'The Art of War',
                'category': 'philosophy',
              }),
              tooltip: 'Increment',
              child: const Icon(Icons.add),
            ),
          ),
        ),
      );
}
5
likes
0
points
29
downloads

Publisher

verified publisherchristianfindlay.com

Weekly Downloads

A Firestore fake library that gives you control over the data

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cloud_firestore, firebase_core, flutter, uuid

More

Packages that depend on firestore_fakes