toHex method

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

Implementation

String toHex({bool leadingHashSign = true, bool includeAlpha = false}) {
  final hex = includeAlpha
    ? toARGB32().toRadixString(16).padLeft(8, '0')
    : toARGB32().toRadixString(16).padLeft(8, '0').substring(2);
  return '${leadingHashSign ? '#' : ''}$hex'.toUpperCase();
}