navii_dart 0.1.0 copy "navii_dart: ^0.1.0" to clipboard
navii_dart: ^0.1.0 copied to clipboard

Deterministic mascot-style avatar generation for Dart. Same seed = same SVG, every time, on every platform. No database, no uploads, no state required.

navii_dart #

pub package CI License: MIT

Pure-Dart deterministic mascot avatar generator. Feed it a string β€” any string β€” and get back a complete, self-contained SVG. Same string β†’ identical SVG on every platform, every time, with no network, no database, no state.

A Dart port of navii by uxderrick.
For the Flutter widget, see navii_flutter.


Features #

  • 🎭 22M+ unique avatars β€” 22 palettes Γ— 8 bodies Γ— 10 eyes Γ— 10 mouths Γ— 5 antennae Γ— 7 accessories Γ— 3 backgrounds Γ— 13 toppers
  • πŸ”’ Deterministic β€” same seed always produces byte-identical SVG output
  • πŸ“΄ Fully offline β€” no network calls, no external assets
  • πŸͺΆ Zero dependencies β€” pure Dart, no runtime packages
  • 🌐 All platforms β€” native, web, server, Flutter

Installation #

dependencies:
  navii_dart: ^0.1.0

Quick start #

import 'package:navii_dart/navii_dart.dart';

// Returns a complete, self-contained SVG string
final String svg = createAvatar('user-123');

// Same seed β†’ identical output, every time
assert(createAvatar('alice') == createAvatar('alice'));

// Use it anywhere SVG strings are accepted
final String svgString = createAvatar('bob@example.com');

Usage #

Basic avatar #

final svg = createAvatar('alice');
// β†’ '<svg xmlns="http://www.w3.org/2000/svg" ...>...</svg>'

Force a specific palette #

final svg = createAvatar('alice', AvatarOptions(paletteId: 'violet'));

Available palette IDs: indigo mint amber sky violet cyan rose lime peach teal sand plum coral forest slate fuchsia terracotta navy lavender charcoal butter aqua

Override the background shape #

final svg = createAvatar('alice', AvatarOptions(background: BackgroundId.ring));
final svg = createAvatar('alice', AvatarOptions(background: BackgroundId.square));
final svg = createAvatar('alice', AvatarOptions(background: BackgroundId.circle));

Custom size #

final svg = createAvatar('alice', AvatarOptions(size: 128));

Lower-level API #

// Resolve the spec without rendering
final AvatarSpec spec = selectAvatar('alice');
print(spec.body);         // e.g. BodyShapeId.tall
print(spec.palette.id);   // e.g. 'violet'

// Render a pre-resolved spec
final String svg = renderAvatar(spec);

Seed guidance #

Use as seed Notes
Database user ID βœ… Best β€” stable, unique
UUID βœ… Great
Email address βœ… Fine β€” changes if email changes
Display name ⚠️ OK β€” changes if user renames

If the seed changes, the avatar changes. Choose something stable.


How it works #

  1. The seed string is hashed with cyrb53 β†’ two 32-bit integers
  2. Those seed the sfc32 PRNG
  3. The PRNG picks one variant from each of 8 part categories, in order
  4. The parts are composed into a single inline SVG string

The algorithm is a faithful port of the original JavaScript navii engine. Output is byte-identical across Dart native, web, and the original JS implementation.


License #

MIT β€” see LICENSE.
Original navii artwork and algorithms Β© uxderrick.

0
likes
150
points
6
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Deterministic mascot-style avatar generation for Dart. Same seed = same SVG, every time, on every platform. No database, no uploads, no state required.

Homepage
Repository (GitHub)
View/report issues

Topics

#avatar #deterministic #svg #mascot #offline

Funding

Consider supporting this project:

github.com

License

MIT (license)

More

Packages that depend on navii_dart