setShorthandGridArea static method

void setShorthandGridArea(
  1. Map<String, String?> properties,
  2. String shorthandValue
)

Implementation

static void setShorthandGridArea(Map<String, String?> properties, String shorthandValue) {
  List<String> parts = shorthandValue.split(_slashRegExp);

  String rowStart = parts.isNotEmpty ? parts[0].trim() : '';
  String columnStart = parts.length > 1 ? parts[1].trim() : '';
  String rowEnd = parts.length > 2 ? parts[2].trim() : '';
  String columnEnd = parts.length > 3 ? parts[3].trim() : '';

  String normalize(String value) => value.isEmpty ? 'auto' : value;

  properties[GRID_ROW_START] = normalize(rowStart);
  properties[GRID_COLUMN_START] = normalize(columnStart);
  properties[GRID_ROW_END] = normalize(rowEnd);
  properties[GRID_COLUMN_END] = normalize(columnEnd);
  final String trimmed = shorthandValue.trim();
  final bool hasSingleToken = parts.length <= 1;
  if (hasSingleToken && CSSGridParser.isCustomIdent(trimmed)) {
    properties[GRID_AREA_INTERNAL] = trimmed;
  } else {
    properties[GRID_AREA_INTERNAL] = 'auto';
  }
}