avataaar_image 1.0.5

avataaar_image #

pub package

Flutter wrapper widget for Avataaars API - a free online avatar generator for anyone to make their beautiful personal avatar easily.

AvataaarImage example

Avataaars #

Credits to Pablo Stanley and Fang-Pen Lin for creating and making Avataaars available to use. 👏

Getting Started #

  1. Create Avataaar object:
// Create avatar with default constructor
  skin: Skin.pale,
  style: Style.circle,
  top: Top.longHairCurly(
    accessoriesType: AccessoriesType.Round,
    facialHair: FacialHair.beardMagestic(
      facialHairColor: FacialHairColor.BlondeGolden,

// Randomize all properties

// Or mix both
  skin: Skin.pale,
  style: Style.circle,
  top: Top.longHairCurly(
    accessoriesType: AccessoriesType.Round,
    facialHair: FacialHair.random,
  1. Create AvataaarImage widget and pass it the avatar:
  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:
  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.

[1.0.5] - 11/05/19

  • Expose avataaars api class

[1.0.4+1] - 08/05/19

  • Update cached_network_image to 0.8.0
  • Fix enum parsing in converter

[1.0.3] - 07/05/19

  • Add copyWith and equals to Avataaar

[1.0.2] - 05/05/19

  • Implement core functionality


import 'package:avataaar_image/avataaar_image.dart';
import 'package:flutter/material.dart';

void main() => runApp(AvataaarExample());

class AvataaarExample extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('Avataaars'), centerTitle: true),
        body: ExampleBody(),

class ExampleBody extends StatefulWidget {
  _ExampleBodyState createState() => _ExampleBodyState();

class _ExampleBodyState extends State<ExampleBody> {
  Avataaar _avatar;

  void initState() {

  void _randomizeAvatar() => _avatar = Avataaar.random();

  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.all(16.0),
      child: Column(children: [
          child: Center(
            child: AvataaarImage(
              avatar: _avatar,
              errorImage: Icon(Icons.error),
              placeholder: CircularProgressIndicator(),
              width: 128.0,
          iconSize: 48.0,
          icon: Icon(Icons.refresh),
          onPressed: () => setState(_randomizeAvatar),

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  avataaar_image: ^1.0.5

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:avataaar_image/avataaar_image.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-0.27 points)

390 out of 400 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (cached_network_image).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
cached_network_image ^0.8.0 0.8.0 1.1.0
flutter 0.0.0
http ^0.12.0+2 0.12.0+2
Transitive dependencies
async 2.2.0
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
flutter_cache_manager 0.3.2 1.1.0
http_parser 3.1.3
meta 1.1.6 1.1.7
path 1.6.2
path_provider 0.5.0+1 1.1.2
pedantic 1.8.0+1
sky_engine 0.0.99
source_span 1.5.5
sqflite 1.1.6+1
string_scanner 1.0.4
synchronized 2.1.0+1
term_glyph 1.1.0
typed_data 1.1.6
uuid 2.0.2
vector_math 2.0.8
Dev dependencies