getLastMessageWidget static method

Widget getLastMessageWidget(
  1. Conversation conversation,
  2. BuildContext context,
  3. Color? iconColor
)

Implementation

static Widget getLastMessageWidget(
  Conversation conversation,
  BuildContext context,
  Color? iconColor,
) {
  BaseMessage message = conversation.lastMessage!;
  String messageType = message.type;
  Widget subtitle;

  final colorPalette = CometChatThemeHelper.getColorPalette(context);

  switch (messageType) {
    case MessageTypeConstants.text:
      subtitle = _getLastTextMessageWidget(conversation, context, iconColor);
      break;
    case MessageTypeConstants.image:
      subtitle = Icon(
        Icons.photo,
        color: iconColor ?? colorPalette.iconSecondary,
        size: 16,
      );
      break;
    case MessageTypeConstants.video:
      subtitle = Icon(
        Icons.videocam,
        color: iconColor ?? colorPalette.iconSecondary,
        size: 16,
      );
      break;
    case MessageTypeConstants.file:
      subtitle = Icon(
        Icons.description,
        color: iconColor ?? colorPalette.iconSecondary,
        size: 16,
      );
      break;
    case MessageTypeConstants.audio:
      subtitle = Icon(
        Icons.mic,
        color: iconColor ?? colorPalette.iconSecondary,
        size: 16,
      );
      break;
    default:
      subtitle = const SizedBox();
  }
  return subtitle;
}