ui_avatar 0.0.2 copy "ui_avatar: ^0.0.2" to clipboard
ui_avatar: ^0.0.2 copied to clipboard

A simple and customizable Flutter widget to generate beautiful text-based avatars using initials, No API needed

UiAvatar #

A simple and customizable Flutter widget to generate beautiful text-based avatars using initials โ€” inspired by avatars in email apps, contact lists, and social platforms. No API needed.

๐ŸŒ Try it online: ui-avatar-playground.web.app Screenshot 2025-04-13 at 10 11 12โ€ฏpm


โœจ Features #

  • Convert names into two-letter initials (e.g., Harkirat Singh โ†’ HS)
  • Circular or rectangular avatars
  • Supports custom background color, text color, font weight, and font family
  • Border support (color + toggle)
  • Option to use random colors (with or without seed)
  • Smart contrast detection for text color
  • Size control and casing customization
  • Lightweight and dependency-free

๐Ÿ“ฆ Installation #

From pub.dev #

dependencies:
  ui_avatar: ^0.0.1

Or use the latest from GitHub #

dependencies:
  ui_avatar:
    git:
      url: https://github.com/0xharkirat/ui_avatar.git

Then run:

flutter pub get

๐Ÿ”จ Usage #

Basic Example #

import 'package:ui_avatar/ui_avatar.dart';

UiAvatar()

Screenshot 2025-04-13 at 10 05 33โ€ฏpm

With Customizations #

UiAvatar(
  name: "Hermione Granger",
  size: 48.0,
  bgColor: Colors.deepPurple,
  textColor: Colors.white,
  shape: BoxShape.rectangle,
  fontWeight: FontWeight.bold,
  isUpperCase: false,
)

Screenshot 2025-04-13 at 10 07 34โ€ฏpm

Use Random Colors (Optional Seeded) #

UiAvatar(
  name: "Ronald Weasley",
  useRandomColors: true,
  useNameAsSeed: true, // same name = same color
)

Screenshot 2025-04-13 at 10 08 10โ€ฏpm

With Border #

UiAvatar(
  name: "Albus Dumbledore",
  useRandomColors: true,
  border: Border.all(color: Colors.white, width: 2),
)

Screenshot 2025-04-13 at 10 09 23โ€ฏpm


๐Ÿ“˜ Parameters #

Property Type Default Description
name String "Harkirat Singh" Full name to extract initials
size double 64.0 Width and height of avatar
bgColor Color Colors.grey Background color (ignored if random)
textColor Color Colors.black Initials color (ignored if random)
fontWeight FontWeight FontWeight.normal Font weight for initials
fontFamily String? null Font family
shape BoxShape BoxShape.circle Shape of avatar
isUpperCase bool true Display initials in upper case
useRandomColors bool false Enable random background + text colors
useNameAsSeed bool true Use name to generate consistent random color
border BoxBorder? null Add a custom border around avatar
boxShadow List<BoxShadow>? null Apply shadow to the avatar box

๐Ÿงช Example Output #

"Harkirat Singh" โ†’ HS
"Albus Percival Wulfric Brian Dumbledore" โ†’ AD
"Harkirat" โ†’ HA
"A" โ†’ A
"" โ†’ ??

๐Ÿ“„ License #

MIT License. Feel free to use and contribute.


๐Ÿ’ก Inspiration #

Inspired by how avatars are shown in apps like Gmail, Notion, and Slack โ€” this package makes it easy to generate visually consistent initials-based avatars in Flutter.

or see very famous api https://ui-avatars.com/ (Not made by me tho).


๐Ÿ‘จโ€๐Ÿ’ป Contributing #

Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.

Last contributor with a merged PR will be featured as the default kDefaultName in UiAvatar!

Steps:

  1. Fork the repo
  2. Create your feature branch (git checkout -b feature/your-feature-name)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature/your-feature-name)
  5. Open a pull request

or just skip steps 2โ€“4. just open the pr directly. be cool. we test in production. we push to production on fridays. peace out.


Fail Fast, Build More & Keep on learning better technologies.

a 0xharkirat production.

1
likes
160
points
42
downloads

Publisher

verified publisher0xharkirat.com

Weekly Downloads

A simple and customizable Flutter widget to generate beautiful text-based avatars using initials, No API needed

Repository (GitHub)

Topics

#avatar #initials #flutter #ui #profile

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on ui_avatar