addColorKeywordHex method Null safety

void addColorKeywordHex(
  1. String colorname,
  2. dynamic hex
)

Add hex color (string or int) to the colorKeywords[] map that is used for dynamic lookup of colors by name.

Implementation

static void addColorKeywordHex(String colorname, dynamic hex) {
  var rgb = hex2rgb(hex);
  int colorInt = 0xff000000 |
      ((rgb[0].toInt() & 0xff) << 16) |
      ((rgb[1].toInt() & 0xff) << 8) |
      (rgb[2].toInt() & 0xff);
  colorKeywords[colorname.toLowerCase().replaceAll(' ', '')] = colorInt;
}