TAvatar class

A customizable avatar widget that supports images, icons, text, and badges.

The TAvatar widget provides a profile/avatar display with flexible configuration options, including shape, size, and additional status indicators such as notifications and online status.

Example Usage:

TAvatar(
  predefinedSize: AvatarSize.medium,
  shape: AvatarShape.circle,
  imageUrl: "https://example.com/avatar.jpg",
  type: AvatarType.online,
)

This will create a medium-sized circular avatar with an image and an online indicator.

Features:

  • Customizable shape (circle or rounded square).
  • Supports predefined sizes or a custom size.
  • Can display an image, icon, or text initials.
  • Optional notification badge or online status indicator.
Inheritance

Constructors

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.

Properties

avatarSize → double
Determines the avatar size based on the predefined size or custom size.
no setter
backgroundColor → Color
Background color of the avatar.
final
badgeSize → double
Determines the size of the notification or online badge.
no setter
borderRadius → double
Determines the border radius for rounded square or circle shape.
no setter
errorIcon → Widget?
final
formattedText → String?
Extracts formatted text initials (first two letters).
no setter
hashCode → int
The hash code for this object.
no setterinherited
icon → Widget?
Optional icon displayed inside the avatar.
final
imageUrl → String?
URL of the image to display inside the avatar.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
loadingIndicator → Widget?
final
notificationCount → int?
Notification count to display in the badge (only applies if type is notification).
final
predefinedSize → AvatarSize?
Predefined avatar size (small, medium, large).
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
shape → AvatarShape
Shape of the avatar (circle or rounded square).
final
size → double?
Custom size of the avatar (overrides predefined sizes if set).
final
text → String?
Text to display inside the avatar (used if no image or icon is provided).
final
textStyle → TextStyle?
Text style for the displayed text.
final
type → AvatarType
Type of avatar (general, with notification badge, or with online indicator).
final

Methods

build(BuildContext context) → Widget
Describes the part of the user interface represented by this widget.
override
createElement() → StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited