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

Extensions for Dart's native Color class.

example/color_ext_example.dart

import 'package:color_ext/color_ext.dart';

void main() {
  // Create a colour using ARGB
  final colour = Colour.fromARGB(0xFF, 0xCC, 0xFF, 0xCC); // #CCFFCC

  // Invert the colour
  final inverted = colour.inverted;
  print(
    "Invert(#CCFFCC): "
    "R: ${inverted.getRed()}, "
    "G: ${inverted.getGreen()}, "
    "B: ${inverted.getBlue()}, "
    "A: ${inverted.getAlpha()}",
  );

  // Scale luminance by 50%
  final halfShade = colour.withLuminance(0.5);
  print(
    "Half-luminance(#CCFFCC): "
    "R: ${halfShade.getRed()}, "
    "G: ${halfShade.getGreen()}, "
    "B: ${halfShade.getBlue()}, "
    "A: ${halfShade.getAlpha()}",
  );

  // Access CMYK channels
  print(
    "CMYK of #CCFFCC: "
    "C: ${colour.c.toStringAsFixed(2)}, "
    "M: ${colour.m.toStringAsFixed(2)}, "
    "Y: ${colour.y.toStringAsFixed(2)}, "
    "K: ${colour.k.toStringAsFixed(2)}",
  );
}
0
likes
150
points
37
downloads

Documentation

API reference

Publisher

verified publishergetconfigured.org

Weekly Downloads

Extensions for Dart's native Color class.

Repository (GitHub)
View/report issues
Contributing

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on color_ext