merge method

ParchmentStyle merge(
  1. ParchmentAttribute attribute
)

Merges this attribute set with attribute and returns result as a new attribute set.

Performs compaction if attribute is an "unset" value, e.g. removes corresponding attribute from this set completely.

See also put method which does not perform compaction and allows constructing styles with "unset" values.

Implementation

ParchmentStyle merge(ParchmentAttribute attribute) {
  final merged = Map<String, ParchmentAttribute>.from(_data);
  if (attribute.isUnset) {
    merged.remove(attribute.key);
  } else {
    merged[attribute.key] = attribute;
  }
  return ParchmentStyle._(merged);
}