text method
Adds a XmlText node with the provided text
.
For example, to generate the text Hello World
one would write:
builder.text('Hello World');
Implementation
void text(Object text) {
final children = _stack.last.children;
if (children.isNotEmpty) {
final lastChild = children.last;
if (lastChild is XmlText) {
// Merge consecutive text nodes into one
lastChild.text += text.toString();
return;
}
}
children.add(XmlTextSyntheticImpl(text.toString()));
}