toMap method Null safety

dynamic toMap()

Implementation

dynamic toMap() {
  if (this.is_array()) {
    List res = [];
    for (int i = 0; i < this.len(); i++) {
      res.add(this[i].toMap());
    }
    return res;
  }
  if (this.is_object()) {
    Map res = {};
    for (final key in this.getKeys()) {
      res[key] = this[key].toMap();
    }
    return res;
  }
  return this.get_value();
}