import '../../../core/api_gateway.dart'; /// Deep copy of a decoded JSON value. /// /// Saved schedules travel back to the server unchanged, so unknown fields (and /// unknown nested values) must survive every round trip without sharing state /// with the reply map that produced them. dynamic cloneJsonValue(dynamic value) { if (value is Map) { return { for (final entry in value.entries) '${entry.key}': cloneJsonValue(entry.value), }; } if (value is List) { return [for (final item in value) cloneJsonValue(item)]; } return value; } JsonMap cloneJsonMap(JsonMap value) => Map.from(cloneJsonValue(value) as Map);