fromHex static method

Color fromHex(
  1. String hexString
)

Creates a Color from a String.

The String follows either of the "RRGGBB" or "AARRGGBB" formats, with an optional leading "#".

Implementation

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