Hashbrowns Static Color Generator

The purpose of Hashbrowns is to generate consistent colors based on the hashcode of an object.


class Genre {
  String name;

class GenrePill extends StatelessWidget {
  final Genre genre;
  late final Hashbrowns hashbrowns;
  GenrePill(this.genre) {
    this.hashbrowns = Hashbrowns.pastels();

  Widget build(BuildContext context) {
    final color = hashbrowns.generateColor(genre);
    return Container(
      color: color.surfaceColor,
      child: Text(genre.name, style: TextStyle(color: color.onSurfaceColor))


Hashbrowns allows consistent color generation based on hashcodes. Simply create a Hashbrowns instance, and pass a hashcode to generateColor, and you will get the same color every time for the same hashcode. `This works especially well for string constants whose hashcodes are consistent across instances.