TAvatar constructor
TAvatar({
- Key? key,
- double? size,
- AvatarSize? predefinedSize,
- AvatarType type = AvatarType.general,
- AvatarShape shape = AvatarShape.circle,
- Widget? icon,
- String? imageUrl,
- String? text,
- Color backgroundColor = Colors.grey,
- TextStyle? textStyle,
- int? notificationCount,
- Widget? errorIcon,
- Widget? loadingIndicator,
Creates an instance of TAvatar.
size: Custom size of the avatar.predefinedSize: Predefined size (small,medium,large).type: Defines avatar behavior (default isgeneral).shape: Defines the shape (circleorroundedSquare).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.',
);