facehash library

Deterministic avatar faces from any string.

FaceHash generates unique, consistent avatar faces based on string hashing. Same input always produces the same face, color, and rotation.

import 'package:facehash/facehash.dart';

// Simple usage
const Facehash(name: 'alice')

// Full customization
Facehash(
  name: 'bob@example.com',
  size: 64,
  shape: FacehashShape.squircle,
  variant: FacehashVariant.solid,
  enableBlink: true,
)

Classes

Facehash
A deterministic avatar widget that generates a unique face from a string.
FacehashData
Immutable data holding the deterministic face properties computed from a name string.

Enums

FacehashShape
Shape of the FaceHash avatar container.
FacehashVariant
Background style variant.
FaceType
The four face types available in FaceHash.
Intensity3D
Controls the strength of the 3D perspective rotation effect.

Constants

defaultColors → const List<Color>
Default color palette using Tailwind CSS color values.
defaultColorsDark → const List<Color>
Dark mode background colors.
defaultColorsLight → const List<Color>
Light mode background colors.

Functions

computeFacehash({required String name, int colorsLength = 5}) FacehashData
Computes deterministic face properties from a name string.
getColor(List<Color>? colors, int index) Color
Gets a color from a palette by index, with fallback to defaultColors.
stringHash(String str) int
Generates a consistent numeric hash from a string.