setCanonicalAlias method

Future<void> setCanonicalAlias(
  1. String canonicalAlias
)

Sets the canonical alias. If the canonicalAlias is not yet an alias of this room, it will create one.

Implementation

Future<void> setCanonicalAlias(String canonicalAlias) async {
  final aliases = await client.getLocalAliases(id);
  if (!aliases.contains(canonicalAlias)) {
    await client.setRoomAlias(canonicalAlias, id);
  }
  await client.setRoomStateWithKey(id, EventTypes.RoomCanonicalAlias, '', {
    'alias': canonicalAlias,
  });
}