dump method
DumpedScalar
dump(
- Object? scalar, {
- required int indent,
- int parentIndent = 0,
- required ScalarStyle? style,
Dumps a scalar.
The scalar is always dumped as a flow node. Consider wrapping the
scalar as a DumpableNode and overriding the NodeStyle if the style
is a ScalarStyle.folded or ScalarStyle.literal.
Implementation
DumpedScalar dump(
Object? scalar, {
required int indent,
int parentIndent = 0,
required ScalarStyle? style,
}) {
final nodeToDump = onObject(scalar);
// Aliases here are returned "as-is".
if (nodeToDump is DumpableAsAlias) {
final alias = nodeToDump.dumpable;
return (
isMultiline: false,
tentativeOffsetFromMargin: indent + alias.length,
node: alias,
);
}
final ConcreteNode(:dumpable, :anchor, :tag) =
nodeToDump as ConcreteNode<Object?>;
final (:isMultiline, :node, :tentativeOffsetFromMargin) = _dumpScalar(
dumpable?.toString() ?? '',
scalarStyle: style ?? defaultStyle,
parentIndent: parentIndent,
indent: indent,
usePlainNull: replaceEmpty,
forceInline: forceInline,
);
return (
isMultiline: isMultiline,
tentativeOffsetFromMargin: tentativeOffsetFromMargin,
node: applyInline(asLocalTag(tag), anchor, node),
);
}