dicebear_offline 1.4.1
dicebear_offline: ^1.4.1 copied to clipboard
A powerful, offline, customizable DiceBear avatar generator for Flutter. Supports OpenPeeps, Personas, Micah, ToonHead, Avataaars, and Miniavs.
dicebear_offline #
A powerful, offline, highly customizable DiceBear avatar generator for Flutter.
This package provides a pure Dart implementation of the beautiful DiceBear avatar styles, allowing you to generate and render SVG avatars entirely offline without making any network requests.
Features #
- 100% Offline: Generates avatars instantly without any network dependencies.
- Multiple Styles: Supports OpenPeeps, Personas, Micah, ToonHead, Avataaars, and Miniavs.
- Highly Customizable: Billions of combinations. Customize hair, eyes, mouth, clothing, colors, accessories, and more.
- Performant: Directly outputs clean SVG strings that can be rendered using
flutter_svg.
Installation #
Add the dependency to your pubspec.yaml:
dependencies:
dicebear_offline: ^1.0.0
flutter_svg: ^2.3.0
Usage #
Import the package and generate an avatar using the SvgEngine:
import 'package:dicebear_offline/dicebear_offline.dart';
import 'package:flutter_svg/flutter_svg.dart';
// Generate an SVG string
final String svgString = SvgEngine.generateSvg(
style: AvatarStyle.personas,
headOrHairKey: 'hairStyle1',
faceOrEyesKey: 'happyEyes',
hairColor: '000000',
skinColor: 'ffdbb4',
clothingColor: '6366f1',
);
// Render it in your Flutter app
SvgPicture.string(svgString)
Check out the example app for a fully featured avatar editor and profile saver demonstrating the complete capabilities of this package!
13-Byte Binary Codec #
You can efficiently compress any avatar configuration into exactly 13 bytes:
// 1. Encode an avatar to 13 bytes
Uint8List bytes = DicebearCodec.encode(
style: AvatarStyle.avataaars,
headOrHairKey: 'longHairCurly',
faceOrEyesKey: 'happy',
// ... pass your other features
);
// 2. Decode the 13 bytes back into a fully rendered SVG!
String svgString = DicebearCodec.decode(bytes);
The codec uses a custom BitWriter to mathematically pack string-based choices across byte boundaries, and utilizes a standard 32-color palette to compress full 24-bit Hex colors into 5 bits.
License #
This project is licensed under the MIT License.