getChildrenProperty<TFormElement> method

  1. @override
Property<List<TFormElement>> getChildrenProperty<TFormElement>({
  1. FormElement? parent,
  2. required String childrenPropertyName,
  3. ElementParserFunction? parser,
  4. bool isContentProperty = false,
  5. bool isImmutable = true,
})
override

Implementation

@override
Property<List<TFormElement>> getChildrenProperty<TFormElement>(
    {FormElement? parent,
    required String childrenPropertyName,
    ElementParserFunction? parser,
    bool isContentProperty = false,
    bool isImmutable = true}) {
  var childrenXmlElement =
      getPropertyAsElement(element, childrenPropertyName);
  if (childrenXmlElement != null) {
    var children = childrenXmlElement.children
        .whereType<XmlElement>()
        .map((c) => parser!(XmlParserNode(c), parent))
        .cast<TFormElement>()
        .toList();
    var childrenProperty = createProperty(children, isImmutable);
    return childrenProperty;
  }

  if (childrenXmlElement == null && isContentProperty) {
    var children = element.children
        .where((c) =>
            c is XmlElement &&
            !c.name.qualified.startsWith(element.name.qualified + '.'))
        .map((c) => parser!(XmlParserNode(c as XmlElement), parent))
        .cast<TFormElement>()
        .toList();
    return createProperty(children, isImmutable);
  }

  return createProperty(<TFormElement>[], isImmutable);
}