'How to get the number of elements in a firebase collection?

Im trying to get the sum of elements in my firebase collection so far ive tried doing

final int documents = await FirebaseFirestore.instance.collection('stations').snapshots().length;

but when i print documents variable with a print statement i get this:

Instance of '_Future<int>'

What should i do ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source