I have an app with a collection 'users' and a subcollection 'Documents'. The 'users' has fields which includes 'Status'. The field 'Status' may have different values. The values include 'Not Verified', 'pending verification' and 'verified'. The admin access the subcollection 'Documents' and clicks on a button which changes the initial 'Status' field fo that a particular user from 'pending verification' to 'verified'. It works well. However, I want that after the admin changes the 'Status' field, that particular data should not be part of the the list anymore. In other words the list should contain only those users whose 'Status' has not been changed yet. I have no idea how to go about it. Any help?
code for accessing the subcollection 'Document':
QueryDocumentSnapshot<Map<String, dynamic>>? pendingVerifications;
StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
stream: FirebaseFirestore.instance
.collectionGroup('Documants')
.snapshots(),
builder: (context, snapshot){
if (snapshot.hasData) {
return ListView.builder(
itemCount: snapshot.data!.docs.length,
itemBuilder: (context, index) { return Card(child: ListTile(
.........
ElevatedButton(onPressed: () async {CollectionReference ref =
FirebaseFirestore.instance.collection('users');
final uid = snapshot.data!.docs[index]['UID'];
ref.doc(uid).set({'Verified'}, SetOptions(merge: true));))}})
So I want that after the click on the elevated button, and after the function is performed, that particular user should be deleted from the listview but not from the database.
Any help?
I recommend that you extract the ListView.builder widget into a separate widget. This will allow you to use an array and update or delete elements from the array.
I hope it helps you. Regards. Btw, sorry if my English is not the best.