title: how to update models in dart
body: <p>if you run the code below you will see that the output is null, which makes total sense since I am assigning the values in the result variable.</p>
  <p>I would expect the <code>result</code> to be 10, something similar to the javascript's Object.assign,
  but I don't know how to do this, because it is not possible to use .addAll</p>
  <pre class="lang-dart prettyprint-override"><code>void main() {
  var a = {&quot;name&quot;: &quot;car&quot;, &quot;value&quot;: 5, &quot;array&quot;: [{&quot;speed&quot;:3}]};
  var b = {&quot;name&quot;: &quot;car&quot;, &quot;value&quot;: 10};
  var c = {&quot;name&quot;: &quot;car&quot;, &quot;array&quot;: [{&quot;speed&quot;:10}]};
  var d = {&quot;name&quot;: &quot;changed&quot;, &quot;array&quot;: [{&quot;speed&quot;:3}]};
  var result = Car();
  result = Car.fromJson(a);
  result = Car.fromJson(b);
  result = Car.fromJson(c);
  result = Car.fromJson(d);
    
  print(result.value); // outputs null, but i expect to print 10
  
  }
  
  // generated via https://javiercbk.github.io/json_to_dart/
  class Car {
    String name;
    int value;
    List&lt;Arr&gt; arr;
  
    Car({this.name, this.value, this.arr});
  
    Car.fromJson(Map&lt;String, dynamic&gt; json) {
      name = json['name'];
      value = json['value'];
      if (json['arr'] != null) {
        arr = new List&lt;Arr&gt;();
        json['arr'].forEach((v) {
          arr.add(new Arr.fromJson(v));
        });
      }
    }
  
    Map&lt;String, dynamic&gt; toJson() {
      final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;();
      data['name'] = this.name;
      data['value'] = this.value;
      if (this.arr != null) {
        data['arr'] = this.arr.map((v) =&gt; v.toJson()).toList();
      }
      return data;
    }
  }
  
  class Arr {
    int speed;
  
    Arr({this.speed});
  
    Arr.fromJson(Map&lt;String, dynamic&gt; json) {
      speed = json['speed'];
    }
  
    Map&lt;String, dynamic&gt; toJson() {
      final Map&lt;String, dynamic&gt; data = new Map&lt;String, dynamic&gt;();
      data['speed'] = this.speed;
      return data;
    }
  }
  </code></pre>