Avatars

Avatars

MUIAvatars

A versatile avatar widget with support for images and fallback text.

Properties

  • imageUrl: String - Image URL for the avatar. If the URL starts with 'http', it is treated as a network image; otherwise, it is treated as an asset image.

  • size: double - Size of the avatar, default: 32.

  • fallbackText: String - Fallback text for the avatar, limited to 2 characters.

  • onTap: VoidCallback - Callback function to be executed when the avatar is tapped.

  • textColor: Color - Text color for the fallback text.

Example Usage

Avatar with url and default size

MUIAvatar(
            imageUrl: "https://github.com/shadcn.png",
            fallbackText: "ABCD",
            onTap: () {},
            textColor: Colors.blue,
          ),

Avatar without url with fallback text and default size

MUIAvatar(
            imageUrl: "",
            fallbackText: "AC",
            onTap: () {},
            textColor: Colors.green,
          ),

Avatar with user defined size

MUIAvatar(
            imageUrl: "",
            fallbackText: "AB",
            size: 50,
            onTap: () {},
            textColor: Colors.red,
          ),**

Avatar with user defined size and url

MUIAvatar(
            imageUrl: "https://github.com/shadcn.png",
            fallbackText: "AB",
            size: 50,
            onTap: () {},
            textColor: Colors.red,
          ),

Notes

  • Provides a customizable avatar with support for images and fallback text.

  • Image URL can be either a network image or an asset image.

  • Fallback text is displayed if the image URL is empty or invalid.

  • Allows customization of size, fallback text, tap callback, and text color.

  • Fallback text is truncated to 2 characters.

Last updated