Color Tools is a library that provies ulitlity functions for the flutter Color class. In comparison to other libaries it tries to avoid adding additonal classes where possible.
- create Color from names
- create Color from color codes
- convert Colors to various types of Strings
- lighten a color
- darken a color
- saturate a color
- desaturate a color
- and more
color_tools provides options to load colors via ColorFrom and add various extensions to the Color class to make it more user friendly.
import 'package:color_tools/color_tools.dart';
final code = ColorFrom.name('red').toCode();
assert(code == '#ff0000')
Create a color from a name
final color = ColorFrom.name('red');
Create a color from a color code
final color = ColorFrom.code('#ff0000');
Generate a specific color from an object. Useful for creating colors for other objects (usernames).
final someObject = "does not have to be a string!";
final color = ColorFrom.object(someObject);
//called for the same object it always gives the same result
assert(ColorFrom.object(someObject) == ColorFrom.object(someObject)) ;
//you can limit the range of possible colors
ColorFrom.object(someObject,
hueLowerLimit: 40, valueLowerLimit: 1, saturationUpperLimit: 1),
Lighten a color
final color = Colors.red.lighten();
Saturate a color
final color = Colors.red.saturate();