AvatarWidget.fromUser constructor

AvatarWidget.fromUser(
  1. User? user, {
  2. Key? key,
  3. AvatarRadius? radius,
  4. double opacity = 1,
  5. AvatarShape shape = AvatarShape.circle,
  6. bool isOnline = false,
  7. bool isAway = false,
  8. BoxConstraints? constraints,
})

Creates an AvatarWidget from the specified user.

Implementation

factory AvatarWidget.fromUser(
  User? user, {
  Key? key,
  AvatarRadius? radius,
  double opacity = 1,
  AvatarShape shape = AvatarShape.circle,
  bool isOnline = false,
  bool isAway = false,
  BoxConstraints? constraints,
}) {
  if (user?.id.isSupport == true) {
    return AvatarWidget.support(
      isOnline: isOnline,
      isAway: isAway,
      radius: radius,
      opacity: opacity,
      shape: shape,
      constraints: constraints,
    );
  }

  return AvatarWidget(
    key: key,
    avatar: user?.avatar,
    title: user?.title(withDeletedLabel: false),
    color: user?.num.val.sum(),
    radius: radius,
    opacity: opacity,
    shape: shape,
    isOnline: isOnline,
    isAway: isAway,
    constraints: constraints,
  );
}