getReplyMessage function

dynamic getReplyMessage(
  1. String messageType,
  2. String? messageTextContent,
  3. String? contactName,
  4. String? mediaFileName,
  5. MediaChatMessage? mediaChatMessage,
  6. bool isReplying,
  7. Color? color,
)

Implementation

getReplyMessage(String messageType,
    String? messageTextContent,
    String? contactName,
    String? mediaFileName,
    MediaChatMessage? mediaChatMessage,
    bool isReplying, Color? color) {
  debugPrint(messageType);
  switch (messageType) {
    case Constants.mText:
      return Row(
        children: [
          Helper.forMessageTypeIcon(Constants.mText),
          Expanded(child: Text(messageTextContent!,style: TextStyle(color: color),maxLines: 1,overflow: TextOverflow.clip,)),
        ],
      );
    case Constants.mImage:
      return Row(
        children: [
          Helper.forMessageTypeIcon(Constants.mImage),
          const SizedBox(
            width: 5,
          ),
          Text(Helper.capitalize(Constants.mImage),style: TextStyle(color: color)),
        ],
      );
    case Constants.mVideo:
      return Row(
        children: [
          Helper.forMessageTypeIcon(Constants.mVideo),
          const SizedBox(
            width: 5,
          ),
          Text(Helper.capitalize(Constants.mVideo),style: TextStyle(color: color)),
        ],
      );
    case Constants.mAudio:
      return Row(
        children: [
          isReplying
              ? Helper.forMessageTypeIcon(
              Constants.mAudio,
              mediaChatMessage != null
                  ? mediaChatMessage.isAudioRecorded
                  : true)
              : const SizedBox.shrink(),
          isReplying
              ? const SizedBox(
            width: 5,
          )
              : const SizedBox.shrink(),
          Text(
            Helper.durationToString(Duration(
                milliseconds: mediaChatMessage != null
                    ? mediaChatMessage.mediaDuration
                    : 0)),style: TextStyle(color: color)

          ),
          const SizedBox(
            width: 5,
          ),
          // Text(Helper.capitalize(Constants.mAudio)),
        ],
      );
    case Constants.mContact:
      return Row(
        children: [
          Helper.forMessageTypeIcon(Constants.mContact),
          const SizedBox(
            width: 5,
          ),
          Text("${Helper.capitalize(Constants.mContact)} :",style: TextStyle(color: color)),
          const SizedBox(
            width: 5,
          ),
          SizedBox(
              width: 120,
              child: Text(
                contactName!,
                maxLines: 1,
                softWrap: false,
                overflow: TextOverflow.ellipsis,style: TextStyle(color: color)
              )),
        ],
      );
    case Constants.mLocation:
      return Row(
        children: [
          Helper.forMessageTypeIcon(Constants.mLocation),
          const SizedBox(
            width: 5,
          ),
          Text(Helper.capitalize(Constants.mLocation),style: TextStyle(color: color)),
        ],
      );
    case Constants.mDocument:
      return Row(
        children: [
          Helper.forMessageTypeIcon(Constants.mDocument),
          const SizedBox(
            width: 5,
          ),
          Flexible(child: Text(
            mediaFileName!, overflow: TextOverflow.ellipsis, maxLines: 1,style: TextStyle(color: color))),
        ],
      );
    default:
      return const SizedBox.shrink();
  }
}