invertColor static method
Inverts Color Hex code Convert string to (4-bit int) and apply bitwise-NOT operation then convert back to Hex String e.g: convert white (FFFFFF) to Dark (000000). Returns Inverted String Color.
Implementation
static String invertColor(String color) {
var invertedColor = <String>[];
for (var i = 0; i < color.length; i++) {
if (color[i].startsWith('#')) {
invertedColor.add('#');
} else {
invertedColor.add(
((~int.parse('0x${color[i]}')).toUnsigned(4)).toRadixString(16));
}
}
return invertedColor.join();
}