cssText property

String get cssText

Textual representation of the declaration block. Setting this attribute changes the style.

Implementation

String get cssText {
  if (length == 0) return EMPTY_STRING;

  final StringBuffer css = StringBuffer();
  bool first = true;

  for (final MapEntry<String, CSSPropertyValue> entry in this) {
    final String property = entry.key;
    final CSSPropertyValue value = entry.value;

    if (!first) css.write(' ');
    first = false;

    css
      ..write(_kebabize(property))
      ..write(': ')
      ..write(value.value);
    if (value.important) {
      css.write(' !important');
    }
    css.write(';');
  }

  return css.toString();
}