toHex method

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

Prefixes a hash sign if leadingHashSign is set to true (default is true).

Implementation

String toHex({bool leadingHashSign = true, bool outputAlpha = false}) =>
    '${leadingHashSign ? '#' : ''}'
    '${outputAlpha ? alpha.toRadixString(16).padLeft(2, '0') : ''}'
    '${red.toRadixString(16).padLeft(2, '0')}'
    '${green.toRadixString(16).padLeft(2, '0')}'
    '${blue.toRadixString(16).padLeft(2, '0')}';