simpleSort method

Custom Sort for Conversation List

Implementation

List<ConversationInfo> simpleSort(List<ConversationInfo> list) => list
  ..sort((a, b) {
    if ((a.isPinned == true && b.isPinned == true) || (a.isPinned != true && b.isPinned != true)) {
      int aCompare = a.draftTextTime! > a.latestMsgSendTime! ? a.draftTextTime! : a.latestMsgSendTime!;
      int bCompare = b.draftTextTime! > b.latestMsgSendTime! ? b.draftTextTime! : b.latestMsgSendTime!;
      if (aCompare > bCompare) {
        return -1;
      } else if (aCompare < bCompare) {
        return 1;
      } else {
        return 0;
      }
    } else if (a.isPinned == true && b.isPinned != true) {
      return -1;
    } else {
      return 1;
    }
  });