Skip to content

lukaswhite/initials_avatar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Initials Avatar

A very simple Flutter widget for displaying an avatar with a user's initials.

Out of the box, it:

  • Extracts the initials from the provided name
  • Sizes the text appropriately
  • Creates a consistent but random background colour
  • Creates a complementary text colour

Usage

At its simplest, simply provide the user's name:

InitialsAvatar(name: 'Joe Bloggs')

Customising

To modify the size (radius):

InitialsAvatar(name: 'Jane Doe', size: 30.0,),

Provide your own background colour:

InitialsAvatar(name: 'Jane Doe', backgroundColor: Colors.pinkAccent,),

Provide your own text colour:

InitialsAvatar(name: 'Jane Doe', textColor: Colors.white,),

The colour of the text is derived from the background colour, by lightening it by default. You can change the degree to which it does so using the textContrastFactor parameter, which is a value between 0 and 100 (which will always be white).

For example:

InitialsAvatar(name: 'Jane Doe', textContrastFactor: 90,),

If you'd prefer to use a darker variant, set the textMode:

InitialsAvatar(name: 'Jane Doe', textMode: InitialsAvatarTextMode.darken,),

The background colour is generated from a built-in selection of colours, but you're free to provide your own:

InitialsAvatar(name: 'Jane Doe', colors: [
    Colors.amber,
    Colors.cyan,
    Colors.brown,
    Colors.pinkAccent
],),

About

A very simple Flutter widget for displaying an avatar with a user's initials.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors