parsePositionShorthand static method

List<String> parsePositionShorthand(
  1. String input
)

Parse background-position shorthand to background-position-x and background-position-y list.

Implementation

static List<String> parsePositionShorthand(String input) {
  if (_cachedParsedPosition.containsKey(input)) {
    return _cachedParsedPosition[input]!;
  }
  List<String> positions = [];
  List<String> split = input.split(_splitRegExp);
  if (split.length == 1) {
    switch(split.first) {
      case TOP:
      case BOTTOM:
        positions.add(CENTER);
        positions.add(split.first);
        break;
      case LEFT:
      case RIGHT:
        positions.add(split.first);
        positions.add(CENTER);
        break;
      default:
        positions.add(split.first);
        positions.add(CENTER);
        break;
    }
  } else if (split.length == 2) {
    positions.add(split.first);
    positions.add(split.last);
  }
  return _cachedParsedPosition[input] = positions;
}