closestColor property

NamedColor? get closestColor

Return the closest NamedColor to this color.

Implementation

NamedColor? get closestColor {
  var min = double.infinity;
  NamedColor? color;
  for (var color in NamedColor.values) {
    var d = color.distanceTo(this);
    if (d < min) {
      min = d;
      color = color;
    }
  }
  return color;
}