apptomate_custom_avatar

A customizable avatar widget for Flutter that supports displaying images, initials, or icons within a circular container.

Features

  • Supports both network and asset images
  • Displays initials if no image is provided
  • Falls back to an icon when no image or initials are available
  • Customizable size, colors, and tap action

📲 Installation

Add the dependency to your pubspec.yaml:

dependencies:
  apptomate_custom_avatar: ^0.0.1

Usage

CustomAvatar(
  imageUrl: "https://example.com/avatar.jpg",
  initials: "SR",
  icon: Icons.person,
  size: 60.0,
  backgroundColor: Colors.blue,
  textColor: Colors.white,
  isNetworkImage: true,
  onTap: () {
    print("Avatar tapped");
  },
)

Example

CustomAvatar(
  initials: "SR",
  size: 50.0,
  backgroundColor: Colors.green,
  textColor: Colors.white,
  onTap: () {
    print("Avatar clicked!");
  },
)

Properties

Property Type Description
imageUrl String? The URL or asset path of the image.
initials String? Initials to display if no image is available.
icon IconData? Icon to display if no image or initials are provided.
size double The size of the avatar.
backgroundColor Color The background color of the avatar.
textColor Color The color of the text and icon.
isNetworkImage bool Determines whether the image is from a network or an asset.
onTap VoidCallback? Callback when the avatar is tapped.