Flutter wrapper widget for Avataaars API.
avataaar_image
Flutter wrapper widget for Avataaars API – a free online avatar generator for anyone to make their beautiful personal avatar easily.
Getting Started
- Create Avataaar object:
// Create avatar with default constructor
Avataaar(
skin: Skin.pale,
style: Style.circle,
top: Top.longHairCurly(
accessoriesType: AccessoriesType.Round,
facialHair: FacialHair.beardMagestic(
facialHairColor: FacialHairColor.BlondeGolden,
),
),
);
// Randomize all properties
Avataaar.random();
// Or mix both
Avataaar.random(
skin: Skin.pale,
style: Style.circle,
top: Top.longHairCurly(
accessoriesType: AccessoriesType.Round,
facialHair: FacialHair.random,
),
);
- Create AvataaarImage widget and pass it the avatar:
AvataaarImage(
avatar: avatar,
errorImage: Icon(Icons.error),
placeholder: CircularProgressIndicator(),
width: 128.0,
);
// By default package will use CachedNetworkImage to render the image. If it doesn't fit your
// needs it's possible to use [builder] constructor and create widget for given image url:
AvataaarImage.builder(
avatar: avatar,
builder: (context, url) {
// ...
},
)
Persisting avatars
Use Avataaar.toJson()
and Avataaar.fromJson(String)
methods to serialize/deserialize avatars.
Getting image bytes
Instantiate AvataaarsApi
object and use its getImage
method or getUrl
if you prefer to handle fetching the data on your own.
Download Source Code on GitHub
Provides the list of the opensource Flutter apps collection with GitHub repository.