toFormattedString method
String
toFormattedString(
- {int nestingLevel = 0,
- String indent = '\t',
- bool encodeCharacterEntities = true,
- String? encodeCharacters,
- bool doubleQuotes = true}
override
Returns this node as a formatted string.
Each child is returned further indented by indent
with
each nestingLevel
.
If lineLength
isn't null
, lines will be broken when they
reach lineLength
in length. Some lines may not be broken
by lineLength
if a clean way to break them can't be detected.
nestingLevel
must not be null
and must be >= 0
.
indent
defaults to \t
(tab) and must not be null
.
lineLength
must not be null
and must be > 0
.
Implementation
@override
String toFormattedString({
int nestingLevel = 0,
String indent = '\t',
bool encodeCharacterEntities = true,
String? encodeCharacters,
bool doubleQuotes = true,
}) {
assert(nestingLevel >= 0);
final tag = _buildTag(
doubleQuotes: doubleQuotes,
encodeCharacterEntities: encodeCharacterEntities,
encodeCharacters: encodeCharacters,
);
var element = tag.formatLine(nestingLevel, indent);
if (children != null) {
element += children!.format(
nestingLevel: nestingLevel,
indent: indent,
encodeCharacterEntities: encodeCharacterEntities,
encodeCharacters: encodeCharacters,
doubleQuotes: doubleQuotes,
);
element += '</$name>'.formatLine(nestingLevel, indent);
}
return element;
}