convertToHexString static method

String convertToHexString(
  1. int r,
  2. int g,
  3. int b, [
  4. num? a,
])

Implementation

static String convertToHexString(int r, int g, int b, [num? a]) {
  var rHex = Color._numAs2DigitHex(Color._clamp(r, 0, 255));
  var gHex = Color._numAs2DigitHex(Color._clamp(g, 0, 255));
  var bHex = Color._numAs2DigitHex(Color._clamp(b, 0, 255));
  var aHex = (a != null)
      ? Color._numAs2DigitHex((Color._clamp(a, 0, 1) * 255).round())
      : '';

  // TODO(terry) 15.toRadixString(16) return 'F' on Dartium not f as in JS.
  //             bug: <http://code.google.com/p/dart/issues/detail?id=2670>
  return '$aHex$rHex$gHex$bHex'.toLowerCase();
}