leaveGroup method
Removes a user from a group
Implementation
Future<void> leaveGroup(String userId, String groupId) async {
try {
// Remove the user from the members array
await _firestore.collection(_collectionPath).doc(groupId).update({
'members': FieldValue.arrayRemove([userId]),
});
// Also remove any location data for this user
await _firestore
.collection(_collectionPath)
.doc(groupId)
.collection(_locationSubcollection)
.doc(userId)
.delete();
} catch (e) {
print('Error leaving group: $e');
rethrow;
}
}