Search packages, repositories and app categories

Package detailsv2.1.0

yaml_writer

A library to write YAML documents, supporting Object encoding and 'dart:convert' 'Converter'.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
666K
Likes
29
Pub points
160

Install package

flutter pub add yaml_writer

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

yaml_writer is a Dart library designed to generate YAML documents with support for object encoding and integration with the 'dart:convert' Converter interface. It enables seamless serialization of Dart objects into structured YAML format, making it ideal for configuration files, data interchange, and persistent storage. The package is compatible across all major platforms including Android, iOS, Web, macOS, Windows, and Linux. With a focus on simplicity and interoperability, it extends the standard Dart ecosystem while maintaining clean, readable output.

Use cases

  • Generating configuration files
  • Serializing Dart objects to YAML
  • Data persistence in YAML format
  • Interoperability with dart:convert
  • Creating structured data exports

Key features

  • Object encoding support
  • Integration with dart:convert Converter
  • Cross-platform compatibility
  • Clean and readable YAML output
  • Simple API for writing YAML documents

Suitable for

  • Developers working with configuration data
  • Applications requiring YAML output
  • Projects using dart:convert utilities
  • Cross-platform Flutter apps
  • Tools that need structured text serialization

Considerations

  • Limited to writing YAML (no parsing)
  • Depends on external dependencies for full functionality
  • Not optimized for large-scale YAML generation
  • No built-in validation of input objects
  • Requires manual handling of complex nested structures

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

yaml_writer

pub package Null Safety Codecov Dart CI GitHub Tag New Commits Last Commits Pull Requests Code size License

A library to write YAML documents, supporting Object encoding and dart:convert Converter.

Usage

A simple usage example:

import 'package:yaml_writer/yaml_writer.dart';

void main() {
  final yamlWriter = YamlWriter();

  final yamlDoc = yamlWriter.write({
    'name': 'Joe',
    'ids': [10, 20, 30],
    'desc': 'This is\na multiline\ntext',
    'enabled': true,
  });

  print(yamlDoc);
}

OUTPUT:

name: "Joe"
ids: 
  - 10
  - 20
  - 30
desc: |-
    This is
    a multiline
    text
enabled: true

YAML Strings

The writer will try to encode strings using the best format depending on the text, avoiding to escape " and using | for multiline texts.

Encoding Objects

You can use YAMLWriter.toEncodable to convert an Object to an encodable version, similar to what is done by dart:convert JsonEncoder.

If YAMLWriter.toEncodable is not set, it will try to call toJson().

Features and bugs

Please file feature requests and bugs at the issue tracker.

Author

Graciliano M. Passos: gmpassos@GitHub.

Liplum: liplum@GitHub

License

Dart free & open-source license.

Categories

Source repository

Projects using this package