1

We have a data model designed in the Firebase for realtime questions and answers. However, we are unable to get realtime counts for a quiz. On researching we are able to see a method addValueEventListener() which refers the DataSnaphot object with the getChildrenCount() One of the reference links for the above info is: android firebase - get childrens count

However, we are unable to find these methods in the Flutter package for Firebase. The link to the package that we are using: https://pub.dartlang.org/packages/firebase_database

Please advise.Thanks.

Dragon
  • 423
  • 9
  • 18

1 Answers1

0

It indeed looks like the child count method is not implement in the FlutterFire library version of DataSnapshot. I'd recommend filing a feature request for it here.

The fastest way to get the feature added would probably to create a PR for it yourself, but that would require you to dig into how the FlutterFire library works under the hood.

Alternatively you can listen to the onChildAdded event, and count the children in your client-side Flutter code. It won't be significantly less efficient, since the regular SDKs also need to download all child nodes to be able to return their count.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807