dice_bear

Creator: coderz1093

Last updated:

Add to Cart

Description:

dice bear

dice_bearFlutter Package
DiceBear API wrapper. DiceBear is an avatar library for designers and developers. Generate random
avatar profile pictures!


Checkout DiceBear
Checkout all avatar styles and licenses here.

Usage #

Import dice_bear
Create Avatar object
Get Uri of generated avatar SVG
Get a Widget using Avatar
Get raw SVG bytes data
DiceBearBuilder() Parameters
DiceBearSprite enum
avatar.toImage() Parameters

Import dice_bear #
import 'package:dice_bear/dice_bear.dart';
copied to clipboard
Create Avatar object #
Avatar _avatar = DiceBearBuilder(
seed: 'your-seed', // Default seed is an empty string if you don't set it
).build();
copied to clipboard
Or generate random Avatar everytime:
Avatar _avatar = DiceBearBuilder.withRandomSeed().build();
copied to clipboard
See below for available DiceBearBuilder() Parameters
Get Uri of generated avatar SVG #
Uri uri = _avatar.svgUri;
copied to clipboard
This Uri is a URL of api.dicebear.com which returns raw SVG data.
Get a Widget using Avatar #
Widget image = _avatar.toImage();
copied to clipboard
See below for available toImage() parameters.
Get raw SVG bytes data #
Uint8List? raw = await _avatar.asRawSvgBytes();
copied to clipboard
DiceBearBuilder() Parameters #
These options affect the SVG. They do not affect the widget created by avatar.toImage(). See avatar.toImage() Parameters below.



Parameter
Details
Default Value
Range
Comment




DiceBearSprite? sprite
Design of avatar to show
DiceBearSprite.any

See all styles


String? seed
Seed for the avatar
''

You can use UID of user to generate a personal avatar of that user.


Color? backgroundColor
Background color
No Color (May or may not be transparent, depending on selected sprite)

Opacity/Alpha does not effect the background color.


int radius
Radius
0
min: 0max: 20



int size
Size of SVG

min: 1
This does not define the size of widget.


int scale
Scale avatar inside SVG container
100
min: 0max: 200



bool flip
Flip avatar horizontally
false




int rotate
Number if degrees to rotate image clockwise
0
min: 0max: 360



int translateX
Translate avatar SVG along X-axis
0
min: -100max: 100



int translateY
Translate avatar SVG along Y-axis
0
min: -100max: 100




DiceBearSprite enum #



Sprite
Example
Comment




DiceBearSprite.any

Sets a random sprite


DiceBearSprite.adventurer




DiceBearSprite.adventurerNeutral




DiceBearSprite.avataaars




DiceBearSprite.avataaarsNeutral




DiceBearSprite.bigEars




DiceBearSprite.bigEarsNeutral




DiceBearSprite.bigSmile




DiceBearSprite.bottts




DiceBearSprite.botttsNeutral




DiceBearSprite.croodles




DiceBearSprite.croodlesNeutral




DiceBearSprite.funEmoji




DiceBearSprite.icons




DiceBearSprite.identicon




DiceBearSprite.initials

Deprecated because avatar.toImage()throws an exception on this sprite


DiceBearSprite.lorelei




DiceBearSprite.loreleiNeutral




DiceBearSprite.micah




DiceBearSprite.miniavs




DiceBearSprite.openPeeps




DiceBearSprite.personas




DiceBearSprite.pixelArt




DiceBearSprite.pixelArtNeutral





avatar.toImage() Parameters #



Parameter
Default Value




Key? key



double? width



double? height



BoxFit fit
BoxFit.contain


Alignment alignment
Alignment.center


bool matchTextDirection
false


bool allowDrawingOutsideViewBox
false


WidgetBuilder? placeholderBuilder



Color? color



BlendMode colorBlendMode
BlendMode.srcIn


String? semanticsLabel



bool excludeFromSemantics
false


Clip clipBehavior
Clip.hardEdge


bool cacheColorFilter
false


SvgTheme? theme

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.