toHex method

String toHex({
  1. bool includeHash = true,
})

Returns the color in Hexadecimal string format (e.g., #FF6200EE).

includeHash : Whether to prepend '#' to the result.

Implementation

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