firebase_model_notifier 0.9.2 copy "firebase_model_notifier: ^0.9.2" to clipboard
firebase_model_notifier: ^0.9.2 copied to clipboard

discontinued

ModelNotifier package for Firebase. When you listen in Firestore, you can tell riverpod and others about the update.

example/lib/main.dart

// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:firebase_model_notifier/firebase_model_notifier.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ProviderScope(
      child: MaterialApp(
        title: "FirestoreModel Notifier Demo",
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: const MyCountUpDemo(),
      ),
    );
  }
}

class MyCountUpDemo extends ConsumerWidget {
  const MyCountUpDemo();

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final document = ref.watch(firestoreDocumentProvider("app/counter"));
    final count = document.get("count", 0);

    return Scaffold(
      appBar: AppBar(
        title: const Text("FirestoreModel Notifier Demo"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              "$count",
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          document["count"] = count + 1;
          document.save();
        },
        tooltip: "Increment",
        child: const Icon(Icons.add),
      ),
    );
  }
}
2
likes
0
pub points
0%
popularity

Publisher

verified publishermathru.net

ModelNotifier package for Firebase. When you listen in Firestore, you can tell riverpod and others about the update.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

cloud_firestore, cloud_functions, firebase_core, flutter, http, katana, katana_firebase, meta, model_notifier

More

Packages that depend on firebase_model_notifier