Loading a YamlSourceNode 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: '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: 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: mappy.toString());
// True.
print(yamlCollectionEquality.equals(node, mappy));
Classes
- AliasNode Introduction Loading a YamlSourceNode Anchors and Aliases
- A node that is a pointer to another node.
- CompactYamlNode Introduction Loading a YamlSourceNode Dumping YAML Nodes
- A YamlNode with a set of node properties. This node is not necessarily limited to YAML's compact notation unless such a notation is required when the object is being dumped.
-
DartNode<
T> Loading a YamlSourceNode -
A simple wrapper for most
Darttypes. Effective if you want to access keys in a Mapping - Mapping Introduction Loading a YamlSourceNode
-
A read-only
YAMLMap which mirrors an actual Dart Map in equality but not shape. -
Scalar<
T> Introduction Loading a YamlSourceNode - Any value that is not a Sequence or Mapping.
- Sequence Introduction Loading a YamlSourceNode
-
A read-only
YAMLList which mirrors an actual Dart List in equality but not shape. - YamlCollectionEquality Loading a YamlSourceNode
-
A
DeepCollectionEqualityimplementation that treats YamlSourceNodes as immutable Dart objects. - YamlNode Introduction Loading a YamlSourceNode
-
A simple node dumpable to a
YAMLsource string - YamlSourceNode Introduction Loading a YamlSourceNode
-
A node parsed from a
YAMLsource string.
Constants
- yamlCollectionEquality → const YamlCollectionEquality Loading a YamlSourceNode
-
A custom
Equalityobject for deep equality. This includes AliasNodes which wrap their YamlSourceNode subclass references.
Functions
-
loadNodes(
{String? source, Iterable< Loading a YamlSourceNodeint> ? byteSource, bool throwOnMapDuplicate = false, List<Resolver> ? resolvers, void logger(bool isInfo, String message)?}) → Iterable<YamlSourceNode> - Loads every document's root node as a YamlSourceNode.
-
loadYamlNode<
T extends YamlSourceNode> ({String? source, Iterable< Loading a YamlSourceNodeint> ? byteSource, bool throwOnMapDuplicate = false, List<Resolver> ? resolvers, void logger(bool isInfo, String message)?}) → T? - Loads the first document's root as a YamlSourceNode
-
yamlSourceNodeDeepEqual(
YamlSourceNode thiz, YamlSourceNode that) → bool Loading a YamlSourceNode -
Checks if 2 YamlSourceNode are equal based on the
YAMLspec.
Enums
- ChompingIndicator Loading a YamlSourceNode
- Controls how final line breaks and trailing empty lines are interpreted.
- NodeStyle Loading a YamlSourceNode
- Indicates how each YamlNode is presented in the serialized yaml string.
- ScalarStyle Loading a YamlSourceNode
- Indicates how each Scalar is presented in a serialized yaml string.