getLastChild method

XmlElement? getLastChild(
  1. String elementName
)

Returns the last direct child named elementName.

Returns null if no element can be found.

Implementation

XmlElement? getLastChild(String elementName) {
  assert(elementName.isNotEmpty);
  if (children == null) return null;
  elementName = elementName.toLowerCase();
  return children!.cast<XmlNode?>().lastWhere(
        (child) =>
            child is XmlElement && child.name.toLowerCase() == elementName,
        orElse: () => null,
      ) as XmlElement?;
}