Flutter Firestore Run Transaction to make your UpVoting counter with FieldValue.arrayUnion
Code: import 'package:flutter/material.dart' ; import 'package:firebase_auth/firebase_auth.dart' ; import 'package:cloud_firestore/cloud_firestore.dart' ; var myDocId, numberOfUpVoters; void addUpVotingField() async { List<String> emptyList = new List (); await FirebaseFirestore. instance .collection( 'YourCollection' ).add({ "OtherField" : "OtherValue" , //... more fields "upVoters" : FieldValue. arrayUnion (emptyList), //to store uid of users who up-voted }).then((DocumentReference documentReference) { myDocId = documentReference. id ; }); } void firestoreTransaction() { User user = FirebaseAuth. instance . currentUser ; DocumentReference documentReference = FirebaseFirestore. instance .collection( 'YourCollection' ).doc(myDocId); FirebaseFirestore. instance .runTransaction((transaction) async { DocumentSnapshot documentSnapshot = await transaction.get(...