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

パッケージ詳細v2.1.1

properties

Dartでプロパティファイル(およびそれ以上)を管理するためのシンプルなライブラリ

AndroidiOSmacOSWindowsLinux
30日間ダウンロード
92.4万
いいね数
9
Pub ポイント
140

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

flutter pub add properties

パッケージ概要

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

properties パッケージは、構成およびローカライズに一般的に使用されるプロパティファイルを管理するための軽量な Dart ライブラリです。標準の .properties 形式でのキーと値のペアの読み取り、書き込み、解析をサポートし、コメントやエンコーディングの処理に役立つ追加ユーティリティも提供しています。このライブラリはプラットフォームに依存せず、Android、iOS、macOS、Windows、Linux でスムーズに動作します。外部依存関係なしにシンプルで構造的な構成ストレージが必要なアプリケーションに最適です。

用途

  • .properties ファイルからアプリケーション設定を読み込んでいます
  • ローカライゼーション文字列の管理
  • 環境固有の設定を保存する
  • 構成データの解析と書き込み
  • プレーンテキスト形式のキー値ペアの処理

主な機能

  • 標準の .properties ファイル形式をサポートしています
  • コメント付きのキー値ペアを読み書きする
  • クロスプラットフォーム互換性
  • 一般的な操作向けのシンプルな API
  • UTF-8 エンコーディングおよび改行の処理

適している対象

  • 設定ファイルを必要とする小規模から中規模のアプリ
  • ローカライゼーションワークフロー
  • 環境ベースの構成
  • 複数のプラットフォームにおけるDartプロジェクト
  • 最小の依存関係を好む開発者

注意事項

  • 複雑なネストされた構成には適していません
  • 平坦なキー値構造に制限される
  • 組み込みの検証またはスキーマサポートなし
  • 大規模なデータ管理よりも、シンプルな利用ケースに最適

元の README

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

Properties

Properties is a simple library to manage properties files (and something more) in Dart.

The project aim is to provide a simple and lightweight implementation of properties file management for Dart adding some useful but not so common features. Code and usage are very straightforward, just have a look at the Getting Started section below.

To know something more about the released version have a look at the CHANGELOG to find the version that works best for you.

Getting started

The best way to get immediately started is to have a look at the unit tests provided along with the source code.

Anyway you can go on reading this quick intro.

Using Properties you can:

  • create a new properties instance from file
Properties p = Properties.fromFile(filepath);
  • get a property out of it
String value = p.get('test.key.1');

..optionally providing a default value..

String defval = p.get('test.key.X', defval:'value X');

..or a default key..

String defkey = p.get('test.key.X', defkey:'test.key.1');
  • get an int, a double or a bool value
int anInt = p.getInt('test.key.integer');
double aDouble = p.getDouble('test.key.double');
bool aBool = p.getBool('test.key.bool');
  • get a list
List<String> list = p.getList('test.key.listofvalues');
  • add a brand new property, choosing whether to overwrite an existing entry or not
bool added = p.add('test.key.3', 'value 3', true);

and then listen to "property added" or "property updated" events

p.onAdd.listen((AddEvent e) {
        eventType = e.type;
        key = e.key;
        value = e.value;
});
  • export the content as a JSON sting, optionally choosing to export key having a given prefix and/or suffix
String jsonexport = p.toJSON([prefix, suffix]);
  • filter and extract property entries that matches custom conditions
Map<String,String> filtered = p.every((s) => s.startsWith('test'));

Running Tests

To run the tests just run the test/properties_test.dart file.

Some Limits

Output on file is not supported (yet!).

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

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