Wassef Hassine
Wassef Hassine

Reputation: 209

Flutter Firebase update value

I'm fetching data from my collection on firebase inside listview :

StreamBuilder<QuerySnapshot>(
            stream: db.collection('encheres').snapshots(),
            builder: (context, AsyncSnapshot snapshot) {
              if (!snapshot.hasData) {
                return Center(
                  child: CircularProgressIndicator(),
                );
              } else
                return Expanded(
                  child: ListView(
                    scrollDirection: Axis.vertical,
                    shrinkWrap: true,
                    children: snapshot.data!.docs.map<Widget>(
                      (doc) {
                        return Card(
                       .
                       .
                       .
                       .
                       );

I wanna update value of certain attribute on onPressed, any ideas how to achieve that ?

And thanks

Upvotes: 0

Views: 347

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 600090

Inside the onPressed handler you can update the document with

doc.reference.update({'field': 'new value'})

Also see the FlutterFire document on updating documentds.

Upvotes: 1

Related Questions