avatar property

Uri? get avatar

The avatar of the room if set by a participant.

Implementation

Uri? get avatar {
  final avatarUrl = getState(EventTypes.RoomAvatar)?.content['url'];
  if (avatarUrl is String) {
    return Uri.tryParse(avatarUrl);
  }

  final heroes = summary.mHeroes;
  if (heroes != null && heroes.length == 1) {
    final hero = getState(EventTypes.RoomMember, heroes.first);
    if (hero != null) {
      return hero.asUser.avatarUrl;
    }
  }
  if (isDirectChat) {
    final user = directChatSDNID;
    if (user != null) {
      return unsafeGetUserFromMemoryOrFallback(user).avatarUrl;
    }
  }
  if (membership == Membership.invite) {
    final userID = client.userID;
    if (userID == null) return null;
    return getState(EventTypes.RoomMember, userID)
        ?.senderFromMemoryOrFallback
        .avatarUrl;
  }
  return null;
}