A color library which can be used to create, convert, alter, and compare colors to be used in both Flutter and the web.
dependencies: color: any
$ pub get
color_wand.dartfile in your app
Color objects can be constructed by either using the factory constructors of the
Color interface or by directly
RgbColor or an
HslColor using one of their constructors.
Color.rgb(red: red, green: green, blue: blue)
Color.rgba(red: red, green: green, blue: blue, alpha: alpha)
Color.rgbo(red: red, green: green, blue: blue, opacity: opacity)
Color.hsl(hue: hue, saturation: saturation, lightness: lightness)
Color.hslo(hue: hue, saturation: saturation, lightnesss: lightness, opacity: opacity)
Colors are immutable, and most of them can be created using const constructors:
Color color = const Color.hex(0x12345678);
Colors can be converted from one color space to another by calling
toHsl on them.
Colors can be compared using the
== operator, which will implicitly convert the color to an
RgbColor and then compare there values.
Colors can be converted to a CSS color string by using one of the different implementations of the
Available formats are:
rgb(red, green, blue)or
rgb(red, green, blue, alpha)
rgba(red, green, blue)or
rgba(red, green, blue, alpha)
hsl(hue, saturation, lightness)or
hsl(hue, saturation, lightness, alpha)
hsla(hue, saturation, lightness)or
hsla(hue, saturation, lightness, alpha)
Most of the formats can be customized to e.g. represent the values as percentages or decimal numbers.
final rgbFormat = RgbFormat(rgbStyle: PercentOrAlpha.alpha); final hslFormat = HslFormat(hueStyle: DegreeOrDecimal.degree); final color = Color.hsl(24, 100, 50); assert(rgbFormat.format(color) == 'rgb(255, 102, 0)'); assert(hslFormat.format(color) == 'hsl(24deg, 100%, 50%)');
0.0.1 ----- * Initial version 0.0.2 ----- * Drop version of meta to 1.0.0 because of compatibility issues with other packages 0.0.3 ----- * Reformat with dartfmt
Add this to your package's pubspec.yaml file:
dependencies: color_wand: ^0.0.3
You can install packages from the command line:
$ pub get
$ flutter pub get
Alternatively, your editor might support
pub get or
flutter pub get.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter, web, other
No platform restriction found in primary library
Maintain an example. (-10 points)
Create a short demo in the
example/ directory to show how to use this package.
Common filename patterns include
color_wand.dart. Packages with multiple examples should provide
For more information see the pub package layout conventions.
Package is pre-v0.1 release. (-10 points)
While nothing is inherently wrong with versions of
0.0.*, it might mean that the author is still experimenting with the general direction of the API.