yaml_extension
The package extends the functionality of the yaml library.
Features
| Method | Used for |
|---|---|
toMap() |
Allows you to convert text data in YAML format to Map<String, dynamic> |
Getting started
To use any functions of the package, just install and import it.
Usage
Below are example of transformations of
pubspec.yaml file of this package
Load pubspec.yaml file of this package as example:
final file = File('pubspec.yaml');
final reader = file.openSync(mode: FileMode.read);
final bytes = reader.readSync(file.lengthSync());
reader.closeSync();
YamlMap creation:
YamlMap yamlSets = loadYaml(utf8.decode(bytes));
Convert YamlMap to Map:
final map = yamlSets.toMap();
Transformation of Map into a human-readable form.
This feature is implemented in toStructuredString()
method of object_extension package:
final structuredString = map.toStructuredString();
Print result:
print('\n$structuredString');
Output:
{
name: 'yaml_extension',
description: 'Provides additional capabilities for yaml package.',
version: '1.1.0',
repository: 'https://github.com/iLnaar/yaml_extension',
environment: {
sdk: '^3.13.7'
},
dev_dependencies: {
lints: '^1.0.0',
test: '^1.16.0'
},
dependencies: {
object_extension: '^1.0.3',
yaml: '^3.1.4'
}
}