properties

Creator: coderz1093

Last updated:

Add to Cart

Description:

properties

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][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);
copied to clipboard

get a property out of it

String value = p.get('test.key.1');
copied to clipboard
..optionally providing a default value..
String defval = p.get('test.key.X', defval:'value X');
copied to clipboard
..or a default key..
String defkey = p.get('test.key.X', defkey:'test.key.1');
copied to clipboard

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');
copied to clipboard

get a list

List<String> list = p.getList('test.key.listofvalues');
copied to clipboard

add a brand new property, choosing whether to overwrite an existing entry or not

bool added = p.add('test.key.3', 'value 3', true);
copied to clipboard
and then listen to "property added" or "property updated" events
p.onAdd.listen((AddEvent e) {
eventType = e.type;
key = e.key;
value = e.value;
});
copied to clipboard

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]);
copied to clipboard

filter and extract property entries that matches custom conditions

Map<String,String> filtered = p.every((s) => s.startsWith('test'));
copied to clipboard
Running Tests #
To run the tests just run the test/properties_test.dart file.
Some Limits #
Output on file is not supported (yet!).

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.