toHex method

String toHex({
  1. bool includeHashSign = false,
  2. bool includeAlpha = true,
})

Implementation

String toHex({bool includeHashSign = false, bool includeAlpha = true}) {
  String hex = value.toRadixString(16).padLeft(8, '0');
  if (!includeAlpha) {
    hex = hex.substring(2);
  }
  if (includeHashSign) {
    hex = '#$hex';
  }
  return hex;
}