title: Flutter - The method 'map' was called on null
body: <p>I'm receiving the following error while trying to add elements from my api JSON using Object Model to <code>DropdownMenuItem</code></p>
  
  <p>here is the error :</p>
  
  <pre><code>The method 'map' was called on null.
  Receiver: null
  Tried calling: map&lt;DropdownMenuItem&lt;Provinces&gt;&gt;(Closure: (Provinces) =&gt; DropdownMenuItem&lt;Provinces&gt;)
  </code></pre>
  
  <p>here is my dart code :</p>
  
  <pre><code>import 'dart:async';
  
  import 'dart:convert';
  import 'package:flutter/material.dart';
  import 'package:sj/utils/constants.dart';
  import 'package:http/http.dart' as http;
  import 'package:sj/models/master/provinces.dart';
  
  class IdCardFormPage extends StatefulWidget {
    @override
    _IdCardFormPageState createState() =&gt; new _IdCardFormPageState();
  }
  
  class _IdCardFormPageState extends State&lt;IdCardFormPage&gt; {
  
    List&lt;Provinces&gt; listProvinces;
    Provinces _selectedProvince;
  
    Future&lt;List&lt;Provinces&gt;&gt; getProvinceList() async {
      //final response = await http.get("${APIConstants.API_BASE_URL}api/masters/provincesList.php");
      final response = await http.get("url");
  
      listProvinces = parseProvinces(response.body);
  
      return parseProvinces(response.body);
    }
  
    List&lt;Provinces&gt; parseProvinces(String responseBody) {
      final parsed = json.decode(responseBody).cast&lt;Map&lt;String, dynamic&gt;&gt;();
  
      return parsed.map&lt;Provinces&gt;((json) =&gt; Provinces.fromJson(json)).toList();
    }
  
  
    @override
    void initState() {
  
      getProvinceList();
  
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      return new Scaffold(
        appBar: new AppBar(title: new Text("MASUK"),),
        body: _provinceContainer(),
      );
    }
  
    Widget _provinceContainer(){
      return new Container(
          child: new InputDecorator(
            decoration: InputDecoration(
                suffixIcon: new Icon(
                  Icons.account_balance,
                  color: Colors.pink,
                ),
                labelText: LoanEntryField.PD_BANKNAME, labelStyle: TextStyle(fontSize: 16.0)
            ),
            isEmpty: _selectedProvince == null,
            child: new DropdownButtonHideUnderline(
              child: new DropdownButton&lt;Provinces&gt;(
                value: _selectedProvince,
                isDense: true,
                onChanged: (Provinces newValue) {
                  setState(() {
                    _selectedProvince = newValue;
                  });
                },
                items: listProvinces.map((Provinces value) {
                  return new DropdownMenuItem&lt;Provinces&gt;(
                    value: value,
                    child: new Text(value.name, style: new TextStyle(fontSize: 16.0),),
                  );
                }).toList(),
              ),
            ),
          ),
          margin: EdgeInsets.only(bottom: 10.0));
    }
  
  }
  </code></pre>
  
  
  
  <pre><code>class Provinces{
    String id;
    String name;
  
    Provinces({this.id, this.name});
  
    factory Provinces.fromJson(Map&lt;String, dynamic&gt; json) {
      return Provinces(
        id: json['id'] as String,
        name: json['name'] as String,
      );
    }
  
  }
  </code></pre>
  
  <p>How to solve this issue?</p>