I'm creating a 2D game in flutter, Using firebase as a backend service. How I can calculate user's rank according to their score. Currently, I'm getting their rank by using the index, But if two or more users have an equal score then how I can show them the same ranking position. Here is the code:
StreamBuilder<QuerySnapshot>(
stream: FirebaseFirestore.instance
.collection('teams')
.orderBy('points', descending: true)
.snapshots(),
builder: (context, snapshot) {
return ListView.builder(
itemCount: snapshot.data.docs.length,
itemBuilder: (context, index) {
return Container(
child: Text('Rank ${index +1}'),
);
});
},
),