Home > front end >  how to write a function to count users in a collection with flutter
how to write a function to count users in a collection with flutter

Time:02-05

final Firestore = FirebaseFirestore.instance.collection("users").doc();

i have a collection users in my database ,using flutter(Dart), can anyone show me how to write a function who count the Numbers of users in This collection and print It on a Dashboard? thank you

CodePudding user response:

    static Future<int> totalFollowers({String userId}) async {
    final collection = FirebaseFirestore.instance
        .collection(ParamsArgus.COLLECTION_USERS)
        .snapshots();
    return collection.length;
    }
  •  Tags:  
  • Related