toName method

String? toName()

get color name

Implementation

String? toName() {
  List<String> colorCodes = colorNames.keys.toList();
  for (String code in colorCodes) {
    num r = int.parse(code.substring(0, 2), radix: 16);
    num g = int.parse(code.substring(2, 4), radix: 16);
    num b = int.parse(code.substring(4, 6), radix: 16);

    if (_color!.red == r && _color!.green == g && _color!.blue == b) {
      return colorNames[code];
    }
  }

  return "";
}