declaration method Null safety

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

Adds a XmlDeclaration node.

For example, to generate a XML declaration with the default version 1.0 and UTF-8 encoding one would write:

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

Implementation

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