fromRxContact static method

Widget fromRxContact(
  1. RxChatContact? contact, {
  2. Key? key,
  3. Avatar? avatar,
  4. AvatarRadius? radius,
  5. double opacity = 1,
  6. bool badge = true,
})

Creates an AvatarWidget from the specified reactive contact.

Implementation

static Widget fromRxContact(
  RxChatContact? contact, {
  Key? key,
  Avatar? avatar,
  AvatarRadius? radius,
  double opacity = 1,
  bool badge = true,
}) {
  if (contact == null) {
    return AvatarWidget.fromContact(
      key: key,
      contact?.contact.value,
      avatar: avatar,
      radius: radius,
      opacity: opacity,
    );
  }

  return Obx(() {
    return AvatarWidget(
      key: key,
      isOnline:
          badge &&
          contact.contact.value.users.length == 1 &&
          contact.user.value?.user.value.online == true,
      isAway:
          badge && contact.user.value?.user.value.presence == Presence.away,
      avatar: contact.user.value?.user.value.avatar,
      title: contact.contact.value.name.val,
      color:
          contact.user.value == null
              ? contact.contact.value.name.val.sum()
              : contact.user.value?.user.value.num.val.sum(),
      radius: radius,
      opacity: opacity,
    );
  });
}