rgbToHex function

String rgbToHex(
  1. RGB color
)

Implementation

String rgbToHex(RGB color) {
  Function toHex = (int x) {
    var hex = x.toRadixString(16);
    return hex.length == 1 ? '0' + hex : hex;
  };
  return "#" + toHex(color.r) + toHex(color.g) + toHex(color.b);
}