declaration method

void declaration({
  1. String version = '1.0',
  2. String? encoding,
  3. Map<String, String> attributes = const {},
})

Adds a XmlDeclaration node.

For example, to generate an XML declaration <?xml version="1.0" encoding="utf-8"?> one would write:

 builder.declaration(encoding: 'UTF-8');

Implementation

void declaration({String version = '1.0', String? encoding, Map<String, String> attributes = const {}}) {
  final declaration = XmlDeclarationSyntheticImpl()
    ..version = version
    ..encoding = encoding;
  attributes.forEach(declaration.setAttribute);
  _stack.last.children.add(declaration);
}