[doc] Add an example.dart file (#64)

Pana suggests to add an example.dart file
here: https://pub.dev/packages/yaml#-analysis-tab-

Closes https://github.com/dart-lang/yaml/issues/45
1 file changed
tree: 4c576b591942d79b65f1563dcb31c50a7f410e9d
  1. benchmark/
  2. example/
  3. lib/
  4. test/
  5. .gitignore
  6. .test_config
  7. .travis.yml
  8. analysis_options.yaml
  9. CHANGELOG.md
  10. libyaml-license.txt
  11. LICENSE
  12. pubspec.yaml
  13. README.md
README.md

A parser for YAML.

Pub Package Build Status

Use loadYaml to load a single document, or loadYamlStream to load a stream of documents. For example:

import 'package:yaml/yaml.dart';

main() {
  var doc = loadYaml("YAML: YAML Ain't Markup Language");
  print(doc['YAML']);
}

This library currently doesn't support dumping to YAML. You should use json.encode from dart:convert instead:

import 'dart:convert';
import 'package:yaml/yaml.dart';

main() {
  var doc = loadYaml("YAML: YAML Ain't Markup Language");
  print(json.encode(doc));
}