YamlSourceNodes topic
YAML allows nodes to be declared using a block or flow style. You can use flow styles in block but not the other way around. Types of node include:
- Scalar - anything that is not a map/list in Dart
- Sequence - list in Dart. Set support not yet available
- Mapping - map in Dart
Scalars
Any node that is not a Sequence or Mapping. By default, its type is inferred out of the box.
final node = loadYamlNode<Scalar>(source: YamlSource.string('24'));
print(yamlCollectionEquality.equals(24, node)); // True.
Sequences (Lists)
An immutable list. Allows all node types to be used.
import 'package:collection/collection.dart';
const yaml = '''
- rookie_yaml. The
- new kid
- in town
''';
final node = loadYamlNode<Sequence>(source: YamlSource.string(yaml));
// True.
print(
yamlCollectionEquality.equals(node, [
'rookie_yaml. The',
'new kid',
'in town',
]),
);
Mapping (Map)
An immutable map. Allows any node type as a key or value just like a Dart map.
// Let's get funky.
const mappy = {
'name': 'rookie_yaml',
'in_active_development': true,
'supports': {
1: 'Full YAML spec',
2: 'Custom tags and resolvers',
}
};
// Built-in Dart types as strings are just flow nodes in yaml
final node = loadYamlNode<Mapping>(
source: YamlSource.string(mappy.toString()),
);
// True.
print(yamlCollectionEquality.equals(node, mappy));
Classes
- AliasNode Introduction YamlSourceNodes Anchors and Aliases
- A node that is a pointer to another node.
- Mapping Introduction YamlSourceNodes
-
A
YAMLMap which mirrors an actual Dart Map in equality and shape. -
Scalar<
T> Introduction YamlSourceNodes - Any value that is not a Sequence or Mapping.
- Sequence Introduction YamlSourceNodes
-
A
YAMLList which mirrors an actual Dart List in equality and shape. - YamlSourceNode Introduction YamlSourceNodes
-
A node parsed from a
YAMLsource string.
Constants
- yamlCollectionEquality → const DeepCollectionEquality YamlSourceNodes
-
A custom
Equalityobject for deep equality. This includes AliasNodes which wrap their YamlSourceNode subclass references.
Functions
-
loadNodes(
YamlSource source, {bool throwOnMapDuplicate = false, List< YamlSourceNodesScalarResolver< ? resolvers, void logger(bool isInfo, String message)?}) → Iterable<Object?> >YamlSourceNode> - Loads every document's root node as a YamlSourceNode.
-
loadYamlNode<
T extends YamlSourceNode> (YamlSource source, {bool throwOnMapDuplicate = false, List< YamlSourceNodesScalarResolver< ? resolvers, void logger(bool isInfo, String message)?}) → T?Object?> > - Loads the first document's root as a YamlSourceNode
-
yamlSourceNodeDeepEqual(
YamlSourceNode thiz, YamlSourceNode that) → bool YamlSourceNodes -
Checks if 2 YamlSourceNode are equal based on the
YAMLspec.
Enums
- ChompingIndicator YamlSourceNodes
- Controls how final line breaks and trailing empty lines are interpreted.
- NodeStyle YamlSourceNodes
-
Indicates how each
CompactYamlNodeis presented in the serialized yaml string. - ScalarStyle YamlSourceNodes
- Indicates how each Scalar is presented in a serialized yaml string.