fromHex static method

Color fromHex(
  1. String hex
)

String is in the format "RRGGBB" or "AARRGGBB" with an optional hash sing "#".

Implementation

static Color fromHex(String hex) {
  final buffer = StringBuffer();
  if (hex.length == 6 || hex.length == 7) buffer.write('ff');
  buffer.write(hex.replaceFirst('#', ''));
  return Color(int.parse(buffer.toString(), radix: 16));
}