changeMetadata method

Future<void> changeMetadata({
  1. required String metadata,
  2. HMSActionResultListener? hmsActionResultListener,
})

Change the metadata that appears inside HMSPeer.metadata. This change is persistent and all peers joining after the change will still see these values.

Parameters:

metadata - metadata is the string data to be set now.

hmsActionResultListener - hmsActionResultListener is a callback whose HMSActionResultListener.onSuccess will be called when the action completes successfully.

Refer changeMetadata guide here

Implementation

Future<void> changeMetadata(
    {required String metadata,
    HMSActionResultListener? hmsActionResultListener}) async {
  var arguments = {"metadata": metadata};
  var result = await PlatformService.invokeMethod(
      PlatformMethod.changeMetadata,
      arguments: arguments);

  if (hmsActionResultListener != null) {
    if (result == null) {
      hmsActionResultListener.onSuccess(
          arguments: arguments,
          methodType: HMSActionResultListenerMethod.changeMetadata);
    } else {
      hmsActionResultListener.onException(
          arguments: arguments,
          methodType: HMSActionResultListenerMethod.changeMetadata,
          hmsException: HMSException.fromMap(result["error"]));
    }
  }
}