toHex method

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

Prefixes a hash sign if leadingHashSign is set to true and returns the hexadecimal string value of the color.

Implementation

String toHex({bool leadingHashSign = true}) => '${leadingHashSign ? '#' : ''}'
    '${a.round().toRadixString(16).padLeft(2, '0')}'
    '${r.round().toRadixString(16).padLeft(2, '0')}'
    '${g.round().toRadixString(16).padLeft(2, '0')}'
    '${b.round().toRadixString(16).padLeft(2, '0')}';