toHex function

String toHex(
  1. Color color, {
  2. bool leadingHashSign = true,
  3. bool withAlpha = true,
})

Implementation

String toHex(Color color,
        {bool leadingHashSign = true, bool withAlpha = true}) =>
    '${leadingHashSign ? '#' : ''}'
    '${_generateAlpha(alpha: ((color.a * 255.0).round() & 0xff), withAlpha: withAlpha)}'
    '${((color.r * 255.0).round() & 0xff).toRadixString(16).padLeft(2, '0').toUpperCase()}'
    '${((color.g * 255.0).round() & 0xff).toRadixString(16).padLeft(2, '0').toUpperCase()}'
    '${((color.b * 255.0).round() & 0xff).toRadixString(16).padLeft(2, '0').toUpperCase()}' /*  .toUpperCase() */;