fromMap static method
Create event from a map during deserialization This is a factory method that should be implemented by concrete event classes
Implementation
static UTXOReservedEvent fromMap(Map<String, dynamic> map) {
// Handle expiresAt - may be String (from JSON) or DateTime (from CBOR/Isar)
final expiresAtValue = map['expiresAt'];
final DateTime expiresAt;
if (expiresAtValue is String) {
expiresAt = DateTime.parse(expiresAtValue);
} else if (expiresAtValue is DateTime) {
expiresAt = expiresAtValue;
} else {
throw ArgumentError('expiresAt must be String or DateTime, got ${expiresAtValue.runtimeType}');
}
return UTXOReservedEvent(
walletId: map['walletId'] as String,
txid: map['txid'] as String,
vout: map['vout'] as int,
reservedByTxId: map['reservedByTxId'] as String,
reservationReason: map['reservationReason'] as String?,
expiresAt: expiresAt,
priority: map['priority'] as int? ?? 0,
eventId: map['eventId'] as String?,
timestamp: map['timestamp'] != null
? (map['timestamp'] is String
? DateTime.parse(map['timestamp'] as String)
: map['timestamp'] as DateTime)
: null,
version: map['version'] as int?,
metadata: map['metadata'] as Map<String, dynamic>?,
);
}