title: How to update Model with the correct value type
body: <p>I have this code that fetch data from internet:</p>
  <pre><code>Future fetchCfo(String barCode, String url) async {
    final response = await http.get(Uri.parse(url + barCode));
    if (response.statusCode == 200) {
      Map&lt;String, dynamic&gt; responseBody = json.decode(utf8.decode(response.bodyBytes));
      responseBody.forEach((key, value) {
        if (value == null) {
          responseBody.update(key, (value) =&gt; &quot;&quot;);
        }
      });
      return CfoModel.fromJson(responseBody);
    } else {
      return null;
    }
  }
  </code></pre>
  <p>And I need to replace the null values ​​according to their type, for example if a field that was supposed to be an integer returns a null I need to replace it with 0, if a field that was supposed to be a list returns a null I need to replace it with a list empty []; and I don't know how to do this, my code replaces Strings but if a null appears in an int field, the code breaks.</p>
  <p>For example, my model:</p>
  <pre><code> String? interfaceStatus;
      bool? trasnP;
      int? id;
      String? name;
      String? date;
      bool? requiredStatus;
      int? numberOf;
      int? numberRegion;
      List? parameters;
  </code></pre>
  <p>In case numberRegion returns a null, I need to replace with <code>0</code>;
  In case Transp returns a null, I need to replace with <code>false</code>;
  in case name returns a null, I need to replace with empty String <code>&quot;&quot;</code>;</p>
  <p>Response I'm getting:</p>
  <pre><code>{
     &quot;interfaceStatus&quot;:&quot;ok&quot;,
     &quot;trasnP&quot;:false,
     &quot;id&quot;:null,
     &quot;name&quot;:null,
     &quot;date&quot;:null,
     &quot;requiredStatus&quot;:true,
     &quot;numberOf&quot;:23,
     &quot;numberRegion&quot;:27,
     &quot;parameters&quot;:null
  }
  </code></pre>
  <p>What I want to return:</p>
  <pre><code>{
     &quot;interfaceStatus&quot;:&quot;ok&quot;,
     &quot;trasnP&quot;:false,
     &quot;id&quot;:0,
     &quot;name&quot;:&quot;&quot;,
     &quot;date&quot;:&quot;&quot;,
     &quot;requiredStatus&quot;:true,
     &quot;numberOf&quot;:23,
     &quot;numberRegion&quot;:27,
     &quot;Parameters&quot;:[
        
     ]
  }
  </code></pre>
  <p>Anyone has a solution for this ?</p>