hashbrowns 0.1.2 copy "hashbrowns: ^0.1.2" to clipboard
hashbrowns: ^0.1.2 copied to clipboard

A static color generator that uses a value's hashcode to generate predictable color combinations.

Hashbrowns Static Color Generator #

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

Usage #

class Genre {
  String name;
  Genre(this.name);
}

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

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

2
likes
140
pub points
0%
popularity

Publisher

verified publishergetformative.com

A static color generator that uses a value's hashcode to generate predictable color combinations.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on hashbrowns