sendMetaData method
Publishes a set_metadata event.
name
is a name to be associated with the event's public
key.
about
is a personal description to be associated with the event's
public key.
picture
is a URL to a profile picture to be associated with the event's
public key.
Note that the transmission of the event to connected relays occurs asynchronously. nostr_dart maintains a message queue for each relay so that messages will be sent one at a time only after the previous message has acknowledged by the relay or a timeout occurs. This requires relays used to support NIP-15 and NIP-20.
The Event returned is the Nostr event that was published.
An ArgumentError is thrown if the private key hasn't been set or if none of the named parameters have been provided.
Example:
var event = nostr.sendMetaData(name: "Bob");
Implementation
Event sendMetaData({String? name, String? about, String? picture}) {
Map<String, String> params = {};
({'name': name, 'about': about, 'picture': picture}).forEach((key, value) {
if (value != null) params[key] = value;
});
if (params.isEmpty) throw ArgumentError("No metadata provided");
final metaData = jsonEncode(params);
final event = Event(_publicKey, EventKind.metaData, [], metaData);
return sendEvent(event);
}