copyWith method

XmlElement copyWith({
  1. String? name,
  2. List<XmlAttribute>? attributes,
  3. List<XmlNode>? children,
  4. bool copyNull = false,
})

Copies this element with the provided values.

name must be > 0 in length if not null.

If copyNull is true, id, attributes, and children will be copied with a value of null if they're not provided with another value, otherwise they will default to this element's values.

Implementation

XmlElement copyWith({
  String? name,
  List<XmlAttribute>? attributes,
  List<XmlNode>? children,
  bool copyNull = false,
}) {
  assert(name == null || name.isNotEmpty);

  if (!copyNull) {
    attributes ??= this.attributes;
    children ??= this.children;
  }

  return XmlElement(
    name: name ?? this.name,
    attributes: attributes,
    children: children,
  );
}