yaml_fluency 2.0.0 copy "yaml_fluency: ^2.0.0" to clipboard
yaml_fluency: ^2.0.0 copied to clipboard

Write YAML using a fluent syntax. Supports the core types you'd expect, and can be extended easily.

example/lib/example.dart

import 'package:uuid/uuid.dart';
import 'package:yaml_fluency/yaml_fluency.dart';

void main() {
  final userWriter = YamlMapWriter()
    ..writeMap(
      'man',
      (man) => man
        ..writeString('email', 'scott@madewithfelt.com')
        ..writeString('displayName', 'shyndman', quoted: false)
        ..writeBool('activated', true)
        ..writeString('bio', stripLeadingSpace('''
          Scott really likes writing Dart.
          How much?
          Quite a bit.
        '''), multiline: true)
        ..writeMap(
          'account',
          (account) => account
            ..writeNumber('loginCount', 5)
            ..writeString(
              'ticket',
              Uuid().v4(),
            ),
        ),
    )
    ..writeMap(
      'dog',
      (dog) => dog
        ..writeString('name', 'Henry')
        ..writeNumber('weight (lbs)', 24.5)
        ..writeBool('awesome', true),
    );
  print(userWriter.toString());
}

String stripLeadingSpace(String string) {
  return string.replaceAllMapped(
      RegExp(r'^\s+(.*)$', multiLine: true), (match) => match[1]);
}
4
likes
140
pub points
0%
popularity

Publisher

verified publishermadewithfelt.com

Write YAML using a fluent syntax. Supports the core types you'd expect, and can be extended easily.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

meta, pedantic

More

Packages that depend on yaml_fluency