Browse SDKs · Flutter
Platform
SDKsFlutter

Create a contact card message

Create a user card message with the OpenIM Flutter SDK.

Copy

Construct a contact card message to recommend a user to participants in a conversation:

Parameters

ParameterTypeRequiredDescription
userIDStringYesTarget user ID recommended by the card.
nicknameStringYesNickname of the target user.
faceURLString?NoAvatar URL of the target user.

Code example

final message = await OpenIM.iMManager.messageManager.createCardMessage(
  userID: userID,
  nickname: nickname,
  faceURL: faceURL,
);

The nickname and avatar in a card message are stored as a point-in-time snapshot and do not update automatically when the user subsequently edits their profile.

Return value

Returns a Future resolving to a card Message object ready for transmission. Its card payload is stored in cardElem.

State changes after the call

Creating a message only constructs the local message data structure in memory; it does not perform network transmission and does not trigger new-message event callbacks. Once constructed, pass the returned Message instance to Send a message to deliver it to a direct or group conversation.