toHex static method

String toHex(
  1. Color color, {
  2. bool withHashSign = true,
})

Converts a Color to a hex string

Implementation

static String toHex(Color color, {bool withHashSign = true}) {
  return '${withHashSign ? '#' : ''}'
      '${color.alpha.toRadixString(16).padLeft(2, '0')}'
      '${color.red.toRadixString(16).padLeft(2, '0')}'
      '${color.green.toRadixString(16).padLeft(2, '0')}'
      '${color.blue.toRadixString(16).padLeft(2, '0')}';
}