addUserMetadata method
Add or overwrite metadata associated with a specific key.
This method stores the provided data buffer as metadata associated with the given key.
If the key already exists, the previous metadata will be overwritten with this new data.
If metadata already exists for the key, it will be overwritten with the new data.
Parameters
- IN key The key used to identify the metadata entry.
- IN userMetadata The buffer containing the metadata to be stored.
Returns
- Returns true if the metadata is successfully added or overwritten, false if the data buffer is null or the operation fails.
Throws
- An exception if it fails to initialize.
Implementation
Future<bool> addUserMetadata(
final String key, final Uint8List userMetadata) async {
final String dataAsString = base64Encode(userMetadata);
final String? resultString = await GemKitPlatform.instance
.getChannel(mapId: -1)
.invokeMethod<String>(
'callObjectMethod',
jsonEncode(<String, Object>{
'id': _pointerId,
'class': 'LogMetadata',
'method': 'addUserMetadata',
'args': <String, String>{'key': key, 'userMetadata': dataAsString},
}),
);
return jsonDecode(resultString!)['result'] as bool;
}