Color.fromKeyword constructor

Color.fromKeyword(
  1. String keyword
)

Implementation

factory Color.fromKeyword(String keyword) {
  final key = keyword.toLowerCase();
  Color c;
  String colorValue;

  // detect named color
  if ((colorValue = colors[key]) != null) {
    c = Color(colorValue.substring(1))..value = keyword;
  } else if (key == transparentKeyword) {
    c = Color.fromList(<num>[0, 0, 0], 0)..value = keyword;
  }

  return c;

//2.3.1
//  Color.fromKeyword = function(keyword) {
//      var c, key = keyword.toLowerCase();
//      if (colors.hasOwnProperty(key)) {
//          c = new Color(colors[key].slice(1));
//      }
//      else if (key === "transparent") {
//          c = new Color([0, 0, 0], 0);
//      }
//
//      if (c) {
//          c.value = keyword;
//          return c;
//      }
//  };
}