title: Flutter: Mapping JSON into List of Objects returns null
body: <p>I have a json of structure</p>
  <pre><code>{
    &quot;message&quot;: &quot;&quot;,
    &quot;status&quot; : &quot;complete&quot;,
    &quot;results&quot;: [
        {
          &quot;id&quot;: 66,
          &quot;user&quot;: {
              &quot;id&quot;: 80,
              &quot;email&quot;: &quot;+fsefs@gmail.com&quot;
          },
            &quot;order&quot;: {
                &quot;id&quot;: 1,
                &quot;customer&quot;: 2,
                &quot;receiver_name&quot;: &quot;Something&quot;,
                &quot;receiver_phone_number&quot;: &quot;464&quot;
          },
            &quot;order&quot;: {
                &quot;id&quot;: 1,
                &quot;customer&quot;: 2,
                &quot;receiver_name&quot;: &quot;Something&quot;,
                &quot;receiver_phone_number&quot;: &quot;464&quot;
            },
            &quot;pickedup_time&quot;: &quot;sksjkns&quot;,
            &quot;delivered_time&quot;: &quot;hkvjsfsf&quot;
        }
      ]
    }
  
  </code></pre>
  <p>and i am parsing the json this way and also trying to map it into a list of objects</p>
  <pre><code>Future&lt;void&gt; get() async{
    res = await http.get(url);
    var json = jsonDecode(res.body);
    objectsJson = json['results'] as List;
    objects = List&lt;Object&gt;.from(objectsJson.map((i) =&gt; Object.fromMap(i))).toList();
  }
  </code></pre>
  <p>where res,objectsJson,objects are a global variables declared as</p>
  <pre><code>var res;
  List&lt;Object&gt; objects;
  var objectsJson;
  </code></pre>
  <p>and this is my class for Object with the method fromMap that i use to create the classes</p>
  <pre><code>class Object{
    int id, customer;
    String 
        receiverName,
        receiverPhoneNumber,
        pickedUpTime,
        deliveredTime;
  
    Object(
          {
          int id,
            int customer,
            String receiverName,
            String receiverPhoneNumber,
            String pickedUpTime,
            String deliveredTime
          }
          );
  
  
    factory Object.fromMap(Map&lt;String, dynamic&gt; json) {
  
      print(json['order']['id'].toString()+
          json['order']['customer'].toString()+
          json['order']['receiver_name'].toString()+
          json['order']['receiver_phone_number'].toString()+
          json['pickedup_time'].toString()+
          json['delivered_time'].toString()
          );
  
      return new Object(
          id: json['order']['id'],
          customer: json['order']['customer'],
          receiverName: json['order']['receiver_name'],
          receiverPhoneNumber: json['order']['receiver_phone_number'],
          pickedUpTime: json['pickedup_time'],
          deliveredTime: json['delivered_time']
          );
    }
  }
  </code></pre>
  <p>as you can see i printed the values out before creating the object and it displayed correctly.
  but when i try to access the object from the list of objects as below from a futurebuilder i get null values throughout.</p>
  <pre><code>FutureBuilder(
    future: get(),
    build: (BuildContext context, AsyncSnapshot snapshot){
      if(snapshot.connectionState == ConnectionState.done){
        print(objects[0].id);
        print(objects[0].customer); 
        print(objects[0].receiverName);
        print(objects[0].receiverPhoneNumber);
        print(objects[0].pickedUpTime);
        print(objects[0].receivdeliveredTimeerName);
        return Container();
      }
      return Container();
    }
  
  }
  
  </code></pre>
  <p>i have printed out the json and it is intact and that can be backed by not getting null but the actual values when i print out the values before returning the object in the class.</p>
  <p>i have tried printing out objects after mapping and this is what i get</p>
  <pre><code>['Instance of Object']
  </code></pre>
  <p>i have also tried adding .toString() to the ones that are strings in returning  the object. For example:</p>
  <pre><code>receiverName: json['order']['receiver_name'].toString()
  </code></pre>
  <p>I dont know where the null is coming from.</p>