evaluate function

Object? evaluate(
  1. Iterable<Object> path,
  2. Map<Object, dynamic>? data
)

Given a path list, this method navigates through data and returns the last path, or null otherwise.

e.g.: 'my', 'key' + {'my': {'key': 'Value!'}} = 'Value!'

Implementation

Object? evaluate(Iterable<Object> path, Map<Object, dynamic>? data) {
  Object? object = data;
  for (final current in path) {
    if (object is Map && object.containsKey(current)) {
      object = object[current];
    } else {
      object = null;
      break;
    }
  }
  return object;
}