StringColor class

Deterministic, UI-optimized color derivation from any string.

Implements the "String Color" specification: a visually consistent color is derived from a string, mapped to a hue and rendered through HSV with perceptually balanced value (brightness) parameters. Designed to read well as text, backgrounds, borders, and indicator dots across dark, light, sepia, ivory, and grey themes.

Two derivation paths are supported and selected automatically:

  • Hexadecimal input (e.g. a Nostr pubkey) is parsed directly as a BigInt.
  • Any other string is hashed via a polynomial of its character codes.

See the spec (NIP-54 wiki article "String Color", kind 30818 / d-tag string-color).

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromString(String input, {Brightness? textBrightness}) Color
Derives a color from an arbitrary input string.

Constants

neutralGrey → const Color
Neutral fallback for empty or invalid inputs (rgb(128, 128, 128)).