replaceElement function

void replaceElement({
  1. required XmlElement launchTheme,
  2. required String name,
  3. required String value,
})

Implementation

void replaceElement({
  required XmlElement launchTheme,
  required String name,
  required String value,
}) {
  launchTheme.children.removeWhere(
    (element) => element.attributes.any(
      (attribute) =>
          attribute.name.toString() == 'name' && attribute.value == name,
    ),
  );

  launchTheme.children.add(
    XmlElement(
      XmlName('item'),
      [XmlAttribute(XmlName('name'), name)],
      [XmlText(value)],
    ),
  );
}