element method Null safety

  1. @override
Parser element()
override

Implementation

@override
Parser element() => super.element().map((list) {
      final TName name = list[1];
      final attributes = list[2].cast<TNode>();
      if (list[4] == XmlToken.closeEndElement) {
        return createElement(name, attributes, [], true);
      } else {
        if (list[1] == list[4][3]) {
          final children = list[4][1].cast<TNode>();
          return createElement(
              name, attributes, children, children.isNotEmpty);
        } else {
          final Token token = list[4][2];
          final lineAndColumn =
              Token.lineAndColumnOf(token.buffer, token.start);
          throw XmlParserException(
              'Expected </${list[1]}>, but found </${list[4][3]}>',
              buffer: token.buffer,
              position: token.start,
              line: lineAndColumn[0],
              column: lineAndColumn[1]);
        }
      }
    });