complementary method

Color complementary()

Generates a complementary color by inverting the current color.

The complementary color is the color that lies opposite to the current color on the color wheel. This is achieved by subtracting each RGB value from 255 (the maximum possible value).

Example:

Color color = Color(0xFF42A5F5);
Color complementaryColor = color.complementary();
print(complementaryColor); // Output: a color that contrasts with the blue color.

Implementation

Color complementary() {
  return Color.fromARGB(
    a.toInt(),
    255 - r.toInt(),
    255 - g.toInt(),
    255 - b.toInt(),
  );
}