fromHex static method

Color fromHex(
  1. String hexString
)

Create a Color from the supplied hexString

  • string is in the format "rrggbb" or "aarrggbb" with an optional leading "#"

Implementation

static Color fromHex(String hexString) {
  var buffer = StringBuffer();

  hexString = hexString.replaceFirst('#', '');
  if (hexString.length == 6) {
    buffer.write('ff');
  }

  buffer.write(hexString);
  return Color(int.parse(buffer.toString(), radix: 16));
}