ez_circle_avatar 0.0.3
ez_circle_avatar: ^0.0.3 copied to clipboard
A simple Flutter widget for displaying circular avatars with initials and a consistent, automatically generated background color based on a name.
ez_circle_avatar #
A simple Flutter widget for displaying circular avatars with initials and a consistent,
automatically generated background color based on a name.
Perfect for quick integration when you need a basic avatar without extensive customization.
Features #
- Name-Based Initials & Consistent Colors: Generates initials and a consistent background color from a given name (handles single, first/last, and multiple names). The same name always produces the same color.
- Easy to Use: Just provide the name.
- Default Icon: Displays a
person_outlineicon when no name is provided. - Handles Name Variations: Trims leading/trailing spaces in names.
- Customizable: Uses the standard Flutter
CircleAvatarwidget, allowing further customization (size, border, etc.). - Available on pub.flutter-io.cn: ez_circle_avatar
Getting started #
-
Add the dependency:
flutter pub add ez_circle_avatar -
Import the package:
import 'package:ez_circle_avatar/ez_circle_avatar.dart';
Usage #
Displaying a basic avatar is as simple as this:
EzCircleAvatar(name: 'Jane Doe') // Different name, different color
EzCircleAvatar(name: 'John') // Handles single names
EzCircleAvatar(name: 'John David Doe') // Handles multiple names
EzCircleAvatar(name: '') // Handles empty name, will show a person_outline icon
EzCircleAvatar(name: 'Jane Doe', radius: 24)
EzCircleAvatar(name: 'John', backgroundColor: Colors.deepPurple)
EzCircleAvatar(name: 'John David Doe', backgroundImage: AssetImage('images/image.png'))
EzCircleAvatar(name: '', child: Icon(Icons.person, color: Colors.white, size: 20)))
And the result will be like this:
![]()
Maintainer #
Contributing #
Contributions are welcome! Please feel free to open issues and submit pull requests.
License #
MIT