Giter Club home page Giter Club logo

dice_bear's Introduction


dice_bear
Flutter Package

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

GitHub stars pub package

  • Checkout DiceBear
  • Checkout all avatar styles and licenses here.

Usage

Import dice_bear

import 'package:dice_bear/dice_bear.dart';

Create Avatar object

Avatar _avatar = DiceBearBuilder(
  seed: 'your-seed',               // Default seed is an empty string if you don't set it
).build();

Or generate random Avatar everytime:

Avatar _avatar = DiceBearBuilder.withRandomSeed().build();

See below for available DiceBearBuilder() Parameters

Get Uri of generated avatar SVG

Uri uri = _avatar.svgUri;

This Uri is a URL of api.dicebear.com which returns raw SVG data.

Get a Widget using Avatar

Widget image = _avatar.toImage();

See below for available toImage() parameters.

Get raw SVG bytes data

Uint8List? raw = await _avatar.asRawSvgBytes();

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: 0
max: 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: 0
max: 200
bool flip Flip avatar horizontally false
int rotate Number if degrees to rotate image clockwise 0 min: 0
max: 360
int translateX Translate avatar SVG along X-axis 0 min: -100
max: 100
int translateY Translate avatar SVG along Y-axis 0 min: -100
max: 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.lorelei
DiceBearSprite.loreleiNeutral
DiceBearSprite.micah
DiceBearSprite.miniavs
DiceBearSprite.openPeeps
DiceBearSprite.personas
DiceBearSprite.pixelArt
DiceBearSprite.pixelArtNeutral
DiceBearSprite.shapes
DiceBearSprite.thumbs

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

dice_bear's People

Contributors

zaifsenpai avatar jonafeucht avatar zimvomatwa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.