avatar_builder_core 0.2.0 copy "avatar_builder_core: ^0.2.0" to clipboard
avatar_builder_core: ^0.2.0 copied to clipboard

Pure Dart library for building avataaars-style cartoon avatars from customizable attributes using SVG. No Flutter dependency.

Avatar Builder Core #

A pure Dart library for building avataaars-style cartoon avatars as SVG strings. No Flutter dependency — works on servers, CLI tools, and any Dart environment.

pub package

Features #

  • Pure Dart — no Flutter or dart:ui dependency
  • 140+ SVG fragments composable into millions of unique avatars
  • Pluggable asset loading via AssetLoader typedef — use filesystem, HTTP, or any custom source
  • Random avatar generation via Avataaar.random()
  • JSON serialisation with toJson() / fromJson()
  • Full customisation: hair, eyes, eyebrows, mouth, facial hair, clothing, accessories, skin color

Getting started #

dependencies:
  avatar_builder_core: ^0.2.0

Usage #

import 'dart:io';
import 'package:avatar_builder_core/avatar_builder_core.dart';

// Provide an AssetLoader that reads SVG fragments from disk.
Future<String> loadAsset(String key) async {
  if (key.isEmpty) return '';
  return File('path/to/assets/$key').readAsString();
}

void main() async {
  // Create a specific avatar
  final avatar = Avataaar(
    topType: TopType.shortHairShortFlat,
    eyeType: EyeType.happy,
    mouthType: MouthType.smile,
    skinColor: SkinColor.light.color,
  );

  // Or generate a random one
  final random = Avataaar.random();

  // Render to SVG string
  final svg = await avatar.toSvg(loadAsset: loadAsset);
  File('avatar.svg').writeAsStringSync(svg);

  // Serialise to/from JSON
  final json = avatar.toJson();
  final restored = Avataaar.fromJson(json);
}

For Flutter apps, use the avatar_builder package which provides AvatarWidget and built-in asset loading.

Customisation options #

Category Enum Options
Style AvatarStyle circle, transparent
Hair / Hat TopType 34 styles
Hair color HairColor 12 colors
Accessories AccessoriesType 7 types
Facial hair FacialHairType 6 types
Eyes EyeType 12 styles
Eyebrows EyebrowType 13 styles
Mouth MouthType 12 styles
Clothing ClotheType 9 types
Clothing color ClotheColor 15 colors
Graphic (on shirts) GraphicType 11 designs
Skin SkinColor 7 tones

License #

BSD 2-Clause License — see LICENSE for details.

0
likes
0
points
128
downloads

Publisher

verified publisherbramp.net

Weekly Downloads

Pure Dart library for building avataaars-style cartoon avatars from customizable attributes using SVG. No Flutter dependency.

Homepage
Repository (GitHub)
View/report issues

Topics

#avatar #svg #avataaars

License

unknown (license)

Dependencies

meta

More

Packages that depend on avatar_builder_core