getMessageIndicatorIcon static method

Widget getMessageIndicatorIcon(
  1. String messageStatus,
  2. bool isSender,
  3. String messageType,
  4. bool isRecalled,
)

Returns a widget representing the appropriate message indicator icon based on the provided parameters.

Parameters:

  • messageStatus: The status of the message (A - Acknowledged, D - Delivered, S - Seen, N - Unsent).
  • isSender: Indicates if the message sender is the sender user.
  • messageType: The type of message.
  • isRecalled: Indicates if the message has been recalled.

Returns:

  • Widget: A widget representing the message indicator icon.

If the message type is not a notification, and the sender is not the current user and the message is not recalled, the appropriate icon is returned based on the message status. If the message type is a notification, or if the sender is the current user or the message is recalled, an Offstage widget is returned to indicate no icon should be displayed.

Implementation

static Widget getMessageIndicatorIcon(String messageStatus, bool isSender,
    String messageType, bool isRecalled) {
  // debugPrint("Message Status ==>");
  // debugPrint("Message Status ==> $messageStatus");
  if (messageType.toUpperCase() != MessageType.isNotification) {
    if (isSender && !isRecalled) {
      if (messageStatus == 'A') {
        return AppUtils.svgIcon(icon: acknowledgedIcon);
      } else if (messageStatus == 'D') {
        return AppUtils.svgIcon(icon: deliveredIcon);
      } else if (messageStatus == 'S') {
        return AppUtils.svgIcon(icon: seenIcon);
      } else if (messageStatus == 'N') {
        return AppUtils.svgIcon(icon: unSendIcon);
      } else {
        return const Offstage();
      }
    } else {
      return const Offstage();
    }
  } else {
    return const Offstage();
  }
}