update method

Future<VIMessageEvent> update({
  1. String? text,
  2. List<Map<String, Object>>? payload,
})

Send text and payload changes to the cloud.

The participant that calls this method should have:

To be informed about the message updating while being offline, participants can subscribe to the VIMessengerNotification.onEditMessage messenger push notification.

Optional text - New text of this message, maximum 5000 characters. If null, message text will not be updated.

Optional payload - New payload of this message. If null, message payload will not be updated.

Implementation

Future<VIMessageEvent> update({
  String? text,
  List<Map<String, Object>>? payload,
}) async {
  try {
    Map<String, dynamic>? data = await _methodChannel.invokeMapMethod(
      'Messaging.updateMessage',
      {
        'conversation': conversation,
        'message': uuid,
        'text': text ?? this.text,
        'payload': payload ?? this.payload
      },
    );
    if (data == null) {
      _VILog._e('VIMessage: update: data was null, skipping');
      throw VIException(
        VIMessagingError.ERROR_INTERNAL,
        'VIMessage:update: data was null',
      );
    }
    return VIMessageEvent._fromMap(data);
  } on PlatformException catch (e) {
    throw VIException(e.code, e.message);
  }
}