title: How can you make dynamic getters/setters in dart
body: <p>I am trying to recreate djangos QueryDict functionality and make a object that can be given a Map and it be a private variable in the object and getters/setters are used to pull from the map dynamically. I have managed to recreate the get() method of it but I am lost on dynamically getting value. Here is what I have so far:</p>
  
  
  
  <pre class="lang-dart prettyprint-override"><code>class QueryMap {
    Map _data;
  
    QueryMap(Map this._data);
  
    dynamic get(String key, [var defaultValue]) {
      if(this._data.containsKey(key)) {
        return this._data[key];
      } else if(defaultValue) {
        return defaultValue;
      } else {
        return null;
      }
    }
  }
  </code></pre>
  
  <p>Here is djangos page on how it works:
  <a href="https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.QueryDict.__getitem__" rel="noreferrer">https://docs.djangoproject.com/en/dev/ref/request-response/#django.http.QueryDict.<strong>getitem</strong></a></p>