gato 0.0.2 copy "gato: ^0.0.2" to clipboard
gato: ^0.0.2 copied to clipboard

outdated

Gato is a dart utility library inspired by javascript lodash library.

Gato #

Gato is a dart utility library inspired by javascript lodash library.

Installation #

1. Depend on it

Add gato: ^0.0.2 to your pubspec.yaml dependencies:

dependencies:
  gato: ^0.0.2

2. Import it

Now in your Dart code, you can use:

import 'package:gato/gato.dart' as gato;

Map functions #

Get #

Get value from a Map by path. Use dot notation in [path] to access nessted keys.

gato.get<T>(Map<String, dynamic> map, String path)

Arguments

  • map (Map<String, dynamic>): The map you want to get value from.
  • path (String): The path of the property to get.

Returns

  • <T>|null: Returns the resolved value or null if the path is not found.

Example

Map map = {'a': {'b': 1}};
var b = gato.get(map, 'a.b');
or
var b = gato.get<int>(map, 'a.b');

Set #

Sets the value at path of map. If a portion of path doesn't exist, it's created.

Map<String, dynamic> set<T>(Map<String, dynamic> map, String path, T value)

Arguments

  • map (Map<String, dynamic>): The map to modify.
  • path (String): The path of the property to set.
  • value (T): The value to set.

Returns

  • Map<String, dynamic>: Returns updated map.

Example

Map map = {'a': {'b': 1}};
map = gato.set(map, 'a.b', 2);
or
map = gato.set<int>(map, 'a.b', 2);

Unset #

Removes the property at path of map.

Map<String, dynamic> unset(Map<String, dynamic> map, String path)

Arguments

  • map (Map<String, dynamic>): The map to modify.
  • path (String): The path of the property to remove.

Returns

  • Map<String, dynamic>: Returns updated map.

Example

Map map = {'a': {'b': 1}, 'c': 2};
map = gato.set(map, 'c'); // {'a': {'b': 1}}
21
likes
0
points
152
downloads

Publisher

unverified uploader

Weekly Downloads

Gato is a dart utility library inspired by javascript lodash library.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on gato