property_map 0.0.12 copy "property_map: ^0.0.12" to clipboard
property_map: ^0.0.12 copied to clipboard

outdatedDart 1 only

PropertyMap allows you to quickly implement property bags in dart. It consists of 2 main classes: PropertyMap and PropertyList. PropertyMap is a wrapper around Map<String, dynamic>. PropertyList is a [...]

property_map #

Introduction #

PropertyMap allows you to quickly implement property bags in dart. It consists of 2 main classes: PropertyMap and PropertyList.

PropertyMap is a wrapper around Map<String, dynamic>. PropertyList is a wrapper around List

By default, they can only take simple objects (as defined in dart:json) and Serializable objects. This way, we can ensure that everything inside a PropertyMap (or PropertyList) is serializable.

Features #

  • Rapid implementation of property bags.
  • Can restrict contents to simple types (as defined in dart:json) and Serializable objects. This is the default.

Getting Started #

1. Add the following to your project's pubspec.yaml and run pub install.

dependencies:
  property_map:
    git: https://github.com/sethillgard/property_map.git

2. Add the correct import for your project.

import 'package:property_map/property_map.dart';

Example #

1. Initialize an AssetManager:

main() {
  // Create a PropertyMap
  var data = new PropertyMap();

  // Just add properties.
  data.name = "Daniel";
  data.age = 25;

  // [] works too, if you prefer it.
  data['phone'] = 621-222-1155;

  // Add a List. It will be automatically converted to a PropertyList.
  data.enemies = ['Lucia', 'John', 'Alex'];

  // But exposes the same API.
  data.enemies.add('Susan');

  // Maps are converted to PropertyMaps so you can compose them.
  data.games = {'important': true, 'fun':true, 'numberOwned':9999};

  // You can simply keep adding properties to nested maps.
  data.games.favorites = ['Braid', 'Portal'];

  // Read values.
  print(data.name);
  print(data.games.favorites[0]);

  // Serialize them all.
  print(data.toJson());
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

PropertyMap allows you to quickly implement property bags in dart. It consists of 2 main classes: PropertyMap and PropertyList. PropertyMap is a wrapper around Map<String, dynamic>. PropertyList is a wrapper around List<dynamic>. The benefit of using them is that they can restrict the data that is added to them. By default, they can only take simple objects (as defined in dart:json) and Serializable objects. This way, we can ensure that everything inside a PropertyMap (or PropertyList) is serializable.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on property_map