color 1.3.0 copy "color: ^1.3.0" to clipboard
color: ^1.3.0 copied to clipboard

outdatedDart 1 only

A simple Dart package exposing a Color class which can be used to create, convert, and compare colors.

Color #

A simple Dart package exposing a Color class which can be used to create, convert, and compare colors.

Installation #

  1. Add this to your package's pubspec.yaml file:
dependencies:
  color: any
  1. Get the package using your IDE's GUI or via command line with
$ pub get
  1. Import the color.dart file in your app
import 'package:color/color.dart';

Usage #

Color objects can be constructed using any of a few available constructors.

To create a color from rgb values, call

Color rgbColor = new Color.rgb(192, 255, 238);
RgbColor rgbColor = new RgbColor(192, 255, 238);

Alternatively, a color can be created from a string containing a hex value with

Color hexColor = new Color.hex('c0ffee');

Colors can be compared using the == operator, which will evaluate to true if the two colors share identical rgb values.

assert(new Color.hex('c0ffee') == new Color.hex('c0ffee'));

Colors can be converted from one color space to another by calling the appropriate toXXXColor method on them.

HslColor hsl = new RgbColor(192, 255, 238).toHslColor();

Colors can be altered using a ColorFilter, which will return a new color in the same color space as the input color with that filter applied to it.

RgbColor grey = ColorFilter.greyscale(new RgbColor(192, 255, 238));
HslColor sepia = ColorFilter.sepia(new HslColor(163.8, 100, 87.6));
30
likes
15
pub points
91%
popularity

Publisher

verified publishermikefenwick.com

A simple Dart package exposing a Color class which can be used to create, convert, and compare colors.

Repository
View/report issues

License

MIT (LICENSE)

More

Packages that depend on color