getEventId static method
Creates the id of an event, based on Nostr specs.
Implementation
static String getEventId({
required int kind,
required String content,
required DateTime createdAt,
required List tags,
required String pubkey,
}) {
final data = [
0,
pubkey,
createdAt.millisecondsSinceEpoch ~/ 1000,
kind,
tags,
content,
];
final serializedEvent = jsonEncode(data);
final bytes = utf8.encode(serializedEvent);
final digest = sha256.convert(bytes);
final id = hex.encode(digest.bytes);
return id;
}