map_enhancer 0.1.0 copy "map_enhancer: ^0.1.0" to clipboard
map_enhancer: ^0.1.0 copied to clipboard

outdated

A plugin which extends Dart's native `Map` type with a couple of handy methods.

map_enhancer #

A plugin which extends Dart's native Map type with a couple of handy methods.

Getting Started #

Import the plugin by:

import 'package:map_enhancer/map_enhancer.dart`;

Usage #

Let's start with a simple Map:

final Map peter = {
  'name': {
    'firstName': 'Peter',
    'lastName': 'Petrelli',
  },
  'age': 29,
};

Get a nested value: #

print(
  peter.get(['name', 'firstName']),
);
// Output: Peter

// or if you prefer the json "dot notation":
print(
  peter.get('name.firstName'.split('.')),
);
// Output: Peter

// call with default value:
print(
  peter.get(
    'name.nickName'.split('.'),
    defaultValue: 'Pete',
  ),
);
// Output: Pete

Set a nested value: #

peter.set(['ability'], 'Empathic mimicry');
print(peter['ability']);
// Output: Empathic mimicry

Remove a nested key: #

peter.unset(['name', 'lastName']);
print(peter['name']['lastName']);
// Output: null
4
likes
40
pub points
43%
popularity

Publisher

unverified uploader

A plugin which extends Dart's native `Map` type with a couple of handy methods.

Repository (GitHub)
View/report issues

License

MIT (license)

More

Packages that depend on map_enhancer