oneOnOneId static method

String oneOnOneId(
  1. String me,
  2. String other
)

Compute a Conversation ID based on participants' ids given.

The order of the parameters does not matter. Use this method if you want to simply create a conversation between two users, not related to a particular product, order or transaction.

Implementation

static String oneOnOneId(String me, String other) {
  List ids = [me, other];
  ids.sort();

  final encoded = json.encode(ids);
  final digest = sha1.convert(utf8.encode(encoded));

  final hash = digest.toString().toLowerCase();
  return hash.substring(0, 20);
}