writeAttributes static method

void writeAttributes(
  1. StringSink out,
  2. Map<String, Object?> attributes
)

Writes attributes as key="value": true as the bare key, false and null not at all, values escaped.

Implementation

static void writeAttributes(StringSink out, Map<String, Object?> attributes) {
  for (final MapEntry(:key, :value) in attributes.entries) {
    switch (value) {
      case null || false:
        break;
      case true:
        out.write(' $key');
      default:
        out.write(' $key="${escapeHtml('$value')}"');
    }
  }
}