extractValue method

dynamic extractValue(
  1. String key
)

Implementation

extractValue(String key) {
  var subKeys = key.split('.');
  dynamic data = this;

  for (var key in subKeys) {
    if (data is String) data = jsonDecode(data);

    if (data is Map) {
      data = data[key];
    } else if (data is List) {
      data = data[key.convert<int>()];
    } else {
      return null;
    }
  }

  return data;
}