createRoute method
//////////// //////////// Creates a new route in Firestore
Implementation
// II.B - CRUD Operations
///////////////
/// Creates a new route in Firestore
Future<String> createRoute(
String userId,
String name,
dynamic routeData,
{
bool isPublic = false,
List<String> sharedWith = const [],
List<String> tags = const [],
}
) async {
try {
// Create the route object
final route = RaliRoute(
name: name,
createdBy: userId,
routeData: routeData,
isPublic: isPublic,
sharedWith: sharedWith,
createdAt: Timestamp.now(),
tags: tags,
);
// Add to Firestore
final docRef = await _firestore.collection(_collectionPath).add(route.toMap());
return docRef.id;
} catch (e) {
print('Error creating route: $e');
rethrow;
}
}