TAvatar constructor

TAvatar({
  1. Key? key,
  2. double? size,
  3. AvatarSize? predefinedSize,
  4. AvatarType type = AvatarType.general,
  5. AvatarShape shape = AvatarShape.circle,
  6. Widget? icon,
  7. String? imageUrl,
  8. String? text,
  9. Color backgroundColor = Colors.grey,
  10. TextStyle? textStyle,
  11. int? notificationCount,
  12. Widget? errorIcon,
  13. Widget? loadingIndicator,
})

Creates an instance of TAvatar.

  • size: Custom size of the avatar.
  • predefinedSize: Predefined size (small, medium, large).
  • type: Defines avatar behavior (default is general).
  • shape: Defines the shape (circle or roundedSquare).
  • icon: Displays an icon inside the avatar.
  • imageUrl: Displays an image inside the avatar.
  • text: Displays text initials inside the avatar.
  • backgroundColor: Background color when no image is present.
  • textStyle: Custom text style for text initials.
  • notificationCount: Number to display in the notification badge.

Note: Only one of icon, imageUrl, or text must be provided.

Implementation

TAvatar({
  super.key,
  this.size,
  this.predefinedSize,
  this.type = AvatarType.general,
  this.shape = AvatarShape.circle,
  this.icon,
  this.imageUrl,
  this.text,
  this.backgroundColor = Colors.grey,
  this.textStyle,
  this.notificationCount,
  this.errorIcon,
  this.loadingIndicator,
}) : assert(
        [icon, text, imageUrl].where((element) => element != null).length ==
            1,
        'Provide either text, imageUrl, or icon.',
      );