パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.1.0

yaml_writer

YAML ドキュメントを書くためのライブラリで、オブジェクトのエンコーディングと 'dart:convert' の 'Converter' をサポートしています。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
66.6万
いいね数
29
Pub ポイント
160

パッケージをインストール

flutter pub add yaml_writer

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

yaml_writer は、オブジェクトのエンコードをサポートし、'dart:convert' Converter インターフェースと統合できる YAML ドキュメントを生成することを目的とした Dart ライブラリです。Dart オブジェクトを構造化された YAML 形式にシリアライズするためのスムーズな機能を提供し、設定ファイル、データ交換、永続的ストレージに最適です。このパッケージは Android、iOS、Web、macOS、Windows、Linux を含むすべての主要プラットフォームで互換性があります。シンプルさと相互運用性を重視しており、標準的な Dart エコシステムを拡張しつつ、明確で読みやすい出力を維持しています。

用途

  • 構成ファイルの生成
  • Dart オブジェクトを YAML にシリアライズする
  • YAML形式でのデータ永続化
  • dart:convert との相互運用性
  • 構造化データエクスポートの作成

主な機能

  • オブジェクトエンコーディングのサポート
  • dart:convert Converter との統合
  • クロスプラットフォーム互換性
  • きれいで読みやすい YAML 出力
  • YAML ドキュメントを書くためのシンプルな API

適している対象

  • 設定データを扱う開発者
  • YAML 出力が必要なアプリケーション
  • dart:convert ユーティリティを使用するプロジェクト
  • クロスプラットフォームのFlutterアプリ
  • 構造化テキストのシリアライズが必要なツール

注意事項

  • YAML の書き込みに限定(パースは不可)
  • 完全な機能を実現するために外部の依存関係に依存しています
  • 大規模なYAML生成には最適化されていません
  • 入力オブジェクトの組み込み検証なし
  • 複雑なネスト構造を手動で処理する必要があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

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.

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト