sendChatroomTextMessage method Null safety

Future<NIMResult<NIMChatroomMessage>> sendChatroomTextMessage(
  1. {required String roomId,
  2. required String text,
  3. bool resend = false,
  4. ChatroomMessageAction? action}
)

Send a text message in the chatroom.

Implementation

Future<NIMResult<NIMChatroomMessage>> sendChatroomTextMessage({
  required String roomId,
  required String text,
  bool resend = false,
  ChatroomMessageAction? action,
}) async {
  return _createMessage({
    'roomId': roomId,
    'text': text,
    'messageType': 'text',
  }).then((messageResult) async {
    if (messageResult.isSuccess) {
      final message = messageResult.data as NIMChatroomMessage;
      await action?.call(message);
      return sendChatroomMessage(message, resend);
    } else {
      return messageResult;
    }
  });
}