toHex method

String toHex(
  1. Color color, {
  2. bool includeHashSign = false,
  3. bool enableAlpha = true,
  4. bool toUpperCase = true,
})

Convert color to hex

Implementation

String toHex(
  Color color, {
  bool includeHashSign = false,
  bool enableAlpha = true,
  bool toUpperCase = true,
}) {
  final String hex =
      (includeHashSign ? '#' : '') +
      (enableAlpha ? _radix(color.alpha) : '') +
      _radix(color.red) +
      _radix(color.green) +
      _radix(color.blue);
  return toUpperCase ? hex.toUpperCase() : hex;
}