getChatId method
Generate a unique chat ID based on user IDs
Implementation
String getChatId(String user1, String user2) {
/// Generates a unique identifier for a chat between two users based on their hash codes.
///
/// The identifier is created by comparing the hash codes of the two user IDs.
/// If the hash code of `user1` is less than or equal to the hash code of `user2`,
/// the identifier is formatted as `"$user1_$user2"`. Otherwise, it is formatted
/// as `"$user2_$user1"`.
///
/// This ensures that the order of the user IDs does not affect the generated identifier,
/// making it consistent regardless of the order in which the users are provided.
///
/// Returns:
/// A string representing the unique identifier for the chat.
return user1.hashCode <= user2.hashCode
? "$user1\_$user2"
: "$user2\_$user1";
}