getUserGroups method
- String userId
Gets all groups a user is a member of
Implementation
Future<List<Group>> getUserGroups(String userId) async {
try {
final querySnapshot = await _firestore
.collection(_collectionPath)
.where('members', arrayContains: userId)
.get();
return querySnapshot.docs.map((doc) =>
Group.fromMap(doc.data(), doc.id)
).toList();
} catch (e) {
print('Error getting user groups: $e');
rethrow;
}
}