pickNewest static method
Chooses the most recently updated of two exported payloads (for local vs. server sync).
Implementation
static String pickNewest(String first, String second) {
final Map<String, Object?>? a = decode(first);
final Map<String, Object?>? b = decode(second);
if (a == null) return b == null ? "" : second;
if (b == null) return first;
final DateTime? timeA = DateTime.tryParse((a["updated"] as String?) ?? "");
final DateTime? timeB = DateTime.tryParse((b["updated"] as String?) ?? "");
if (timeA != null && timeB != null) return timeB.isAfter(timeA) ? second : first;
return second.length > first.length ? second : first;
}