buildSummaryText static method

String buildSummaryText(
  1. NIMMessage? message
)

Implementation

static String buildSummaryText(NIMMessage? message) {
  if (message == null) {
    return '';
  }
  switch (message.messageType) {
    case NIMMessageType.text:
      final text = message.text ?? '';
      return text.length > 30 ? text.substring(0, 30) : text;
    case NIMMessageType.image:
      return S.of().chatMessageBriefImage;
    case NIMMessageType.file:
      final attachment = message.attachment;
      final fileBrief = S.of().chatMessageBriefFile;
      if (attachment is NIMMessageFileAttachment &&
          attachment.name?.isNotEmpty == true) {
        return '$fileBrief ${attachment.name}';
      }
      return fileBrief;
    case NIMMessageType.audio:
      return S.of().chatMessageBriefAudio;
    case NIMMessageType.video:
      return S.of().chatMessageBriefVideo;
    default:
      return S.of().chatMessageBriefMessage;
  }
}