updateSession function
Updates a session with the given start time in the TTL content.
Implementation
String updateSession(
String currentContent,
String startTime,
Map<String, dynamic> updatedData,
) {
List<Map<String, String>> sessions = parseSessions(currentContent);
final index = sessions.indexWhere(
(s) => s['start'] == startTime,
);
if (index != -1) {
final session = sessions[index];
if (updatedData.containsKey('title')) {
session['title'] = updatedData['title'].toString();
}
if (updatedData.containsKey('description')) {
session['description'] = updatedData['description'].toString();
}
if (updatedData.containsKey('type')) {
session['type'] = updatedData['type'].toString();
}
// We don't usually update start/end times via UI but keeping it flexible
if (updatedData.containsKey('end')) {
session['end'] = updatedData['end'].toString();
}
sessions[index] = session;
}
return serializeSessions(sessions);
}