getRoutesSharedWith method

Future<List<RaliRoute>> getRoutesSharedWith(
  1. String userId
)

Gets routes shared with a specific user

Implementation

Future<List<RaliRoute>> getRoutesSharedWith(String userId) async {
  try {
    final querySnapshot = await _firestore
        .collection(_collectionPath)
        .where('sharedWith', arrayContains: userId)
        .get();

    return querySnapshot.docs.map((doc) =>
        RaliRoute.fromMap(doc.data(), doc.id)
    ).toList();
  } catch (e) {
    print('Error getting shared routes: $e');
    rethrow;
  }
}