title: The argument type 'x' can't be assigned to the parameter type 'x'
body: <p>Below is my model class:</p>
  
  <p><strong>crm_dependent_list_model.dart (Model class)</strong></p>
  
  <pre><code>import 'crm_dep_entitlement_model.dart';
  
  class DependantModel{
  
    String name;
    String relationship;
    EntitlementsModel entitlements;
  
    DependantModel({this.name, this.relationship, this.entitlements});
  
    factory DependantModel.fromJson(Map depjson){
  
      return DependantModel(
        name: depjson["Name"].toString(),
        relationship: depjson["Relationship"].toString(),
        entitlements: EntitlementsModel.fromJson(depjson["Entitlements"])
      );
    }
  }
  </code></pre>
  
  <p>This is the <strong>EntitlementsModel</strong> located inside <strong>DependantModel class</strong></p>
  
  <p><strong>crm_dep_entitlement_model.dart</strong></p>
  
  <pre><code>class EntitlementsModel{
  
    final GP gp;
    final OPS ops;
    final IP ip;
    final Dental dental;
    final Optical optical;
    final EHS ehs;
  
    EntitlementsModel({this.gp, this.ops, this.ip, this.dental, this.optical, this.ehs});
  
    factory EntitlementsModel.fromJson(Map ejson){
  
      return EntitlementsModel(
  
        gp: GP.fromJson(ejson["GP"]),
        ops: OPS.fromJson(ejson["OPS"]),
        ip: IP.fromJson(ejson["IP"]),
        dental: Dental.fromJson(ejson["Dental"]),
        optical: Optical.fromJson(ejson["Optical"]),
        ehs: EHS.fromJson(ejson["EHS"])
      );
    }
  
  }
  
  
  //GP class
  class GP{
  
    final String entitlement, utilisation, balance;
  
    GP({this.entitlement, this.utilisation, this.balance});
  
    factory GP.fromJson(Map gjson){
  
      return GP(
        entitlement: gjson["Entitlement"].toString(),
        utilisation: gjson["Utilisation"].toString(),
        balance:  gjson["Balance"].toString()
      );
    }
  }
  
  
  //OPS class
  class OPS{
  
    final String entitlement, utilisation, balance;
  
    OPS({this.entitlement, this.utilisation, this.balance});
  
    factory OPS.fromJson(Map gjson){
  
      return OPS(
          entitlement: gjson["Entitlement"].toString(),
          utilisation: gjson["Utilisation"].toString(),
          balance:  gjson["Balance"].toString()
      );
    }
  }
  
  //IP class
  class IP{
  
    final String entitlement, utilisation, balance;
  
    IP({this.entitlement, this.utilisation, this.balance});
  
    factory IP.fromJson(Map gjson){
  
      return IP(
          entitlement: gjson["Entitlement"].toString(),
          utilisation: gjson["Utilisation"].toString(),
          balance:  gjson["Balance"].toString()
      );
    }
  }
  
  
  //Dental class
  class Dental{
  
    final String entitlement, utilisation, balance;
  
    Dental({this.entitlement, this.utilisation, this.balance});
  
    factory Dental.fromJson(Map gjson){
  
      return Dental(
          entitlement: gjson["Entitlement"].toString(),
          utilisation: gjson["Utilisation"].toString(),
          balance:  gjson["Balance"].toString()
      );
    }
  }
  
  
  //Optical class
  class Optical{
  
    final String entitlement, utilisation, balance;
  
    Optical({this.entitlement, this.utilisation, this.balance});
  
    factory Optical.fromJson(Map gjson){
  
      return Optical(
          entitlement: gjson["Entitlement"].toString(),
          utilisation: gjson["Utilisation"].toString(),
          balance:  gjson["Balance"].toString()
      );
    }
  }
  
  
  //EHS class
  class EHS{
  
    final String entitlement, utilisation, balance;
  
    EHS({this.entitlement, this.utilisation, this.balance});
  
    factory EHS.fromJson(Map gjson){
  
      return EHS(
          entitlement: gjson["Entitlement"].toString(),
          utilisation: gjson["Utilisation"].toString(),
          balance:  gjson["Balance"].toString()
      );
    }
  }
  </code></pre>
  
  <p>This model class is currently being used to pull data from JSON in this class:</p>
  
  <p><strong>Fifth.dart (class calling the JSON data)</strong></p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:emas_app/Dependant.dart' as Dep;
  import 'model/crm_dependent_list_model.dart';
  import 'dart:convert';
  import 'dart:async';
  import 'package:http/http.dart' as http;
  
  final String url = "http://crm.emastpa.com.my/MemberInfo.json";
  
  //Future to get list of dependent names
  Future&lt;List&lt;DependantModel&gt;&gt; fetchUserInfo() async{
  
    http.Response response = await http.get(url);
    var responsejson = json.decode(response.body);
  
    return(responsejson[0]['Dependents'] as List)
        .map((user) =&gt; DependantModel.fromJson(user))
        .toList();
  }
  
  class Fifth extends StatefulWidget {
    @override
    _FifthState createState() =&gt; _FifthState();
  }
  
  class _FifthState extends State&lt;Fifth&gt; {
  
    static Future&lt;List&lt;DependantModel&gt;&gt; depState;
  
    @override
    void initState() {
      depState = fetchUserInfo();
      super.initState();
    }
  
      @override
    Widget build(BuildContext context) {
  
        //ListView.builder inside FutureBuilder
        var futureBuilder = new FutureBuilder(
            future: depState,
            builder: (context, snapshot){
              switch(snapshot.connectionState){
                case ConnectionState.none:
                case ConnectionState.waiting:
                  return new Center(
                    child: new CircularProgressIndicator(),
                  );
                default:
                  if(snapshot.hasError){
                    return new Text(snapshot.error);
                  }else{
  
                    List&lt;DependantModel&gt; user = snapshot.data;
  
                    return new ListView.builder(
                        itemCount: user.length,
                        itemBuilder: (context, index){
  
                          return new Column(
                            children: &lt;Widget&gt;[
                              new ListTile(
                                title: new Text(user[index].name,
                                    style: TextStyle(fontSize: 20.0)),
                                subtitle: new Text(user[index].relationship,
                                    style: TextStyle(fontSize: 15.0)),
                                trailing: new MaterialButton(color: Colors.greenAccent,
                                    textColor: Colors.white,
                                    child: new Text("More"),
                                    onPressed: (){
                                      Navigator.push(context,
                                          new MaterialPageRoute(builder: (context) =&gt; Dep.Dependents(name: user[index].name, entitlementsModel: user[index].entitlements))
                                      );
                                    }
                                ),
                              )
                            ],
                          );
                        });
                  }
              }
            });
  
        return new Scaffold(
            body: futureBuilder,
        );
    }
  }
  </code></pre>
  
  <p>The <strong>Fifth.dart</strong> class will send over data through the constructor in this class:</p>
  
  <p><strong>Dependent.dart (class with the constructor)</strong></p>
  
  <pre><code>import 'model/crm_dep_entitlement_model.dart';
  import 'package:flutter/material.dart';
  import 'dart:convert';
  import 'dart:async';
  import 'package:http/http.dart' as http;
  import 'model/crm_dependent_list_model.dart';
  import 'package:flutter/foundation.dart';
  
  final String url = "http://crm.emastpa.com.my/MemberInfo.json";
  
  //Future method to fetch information
  Future&lt;EntitlementsModel&gt; fetchEntitlements() async{
  
    final response =  await http.get(url);
    final jsonresponse = json.decode(response.body);
  
    var res = jsonresponse[0]["Dependents"][0]["Entitlements"];
  
    return EntitlementsModel.fromJson(jsonresponse[0]["Dependents"][0]["Entitlements"]);
  }
  
  //void main() =&gt; runApp(Dependents());
  class Dependents extends StatefulWidget {
  
    final String name;
  //  final Map entitlement;
    final EntitlementsModel entitlementsModel;
  
    //Constructor to accept the value from Fifth.dart
  //  Dependents({Key key, this.name, this.dependantModel) : super(key: key);
    Dependents({Key key, this.name, this.entitlementsModel}) : super(key:key);
  
    @override
    _DependentsState createState() =&gt; _DependentsState();
  }
  
  class _DependentsState extends State&lt;Dependents&gt; {
  
    Future&lt;EntitlementsModel&gt; entitlement;
  
    @override
    void initState() {
      entitlement = fetchEntitlements();
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
  
      //new body widget
      Widget body = new Container(
        child: new Center(
          child: new FutureBuilder(
              future: entitlement,
              builder: (context, snapshot){
                if(snapshot.hasData){
                  var entitledata = snapshot.data;
  
                  //retrieve data from snapshot
                  var gpentitlement = entitledata.gp.entitlement;
                  var gputilisation = entitledata.gp.utilisation;
                  var gpbalance = entitledata.gp.balance;
  
                  var opsentitle = entitledata.ip.entitlement;
                  var opsutilisation = entitledata.ip.utilisation;
                  var opsbalance = entitledata.ip.balance;
  
                  return new Column(
                    children: &lt;Widget&gt;[
                      new ListTile(
                        title: new Text("Name: "),
                        subtitle: new Text("${widget.name}"),
                      )  ,
                      new Divider(
                        color: Colors.black,
                      ),
                      new ListTile(
                        title: new Text("Clinic GP",
                          style: TextStyle(
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                      ) ,
                      new ListTile(
                        title: new Text("Entitlement"),
                        trailing: new Text(gpentitlement),
                      ),
                      new ListTile(
                        title: new Text("Utilisation"),
                        trailing: new Text(gputilisation),
                      ),
                      new ListTile(
                        title: new Text("Balance"),
                        trailing: new Text(gpbalance),
                      ),
                      new Divider(
                        color: Colors.black,
                      ),
                      new ListTile(
                        title: new Text("IP",
                          style: TextStyle(
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                      ),
                      new ListTile(
                        title: new Text("Entitlement"),
                        trailing: new Text(opsentitle),
                      ),
                      new ListTile(
                        title: new Text("Utilisation"),
                        trailing: new Text(opsutilisation),
                      ),
                      new ListTile(
                        title: new Text("Balance"),
                        trailing: new Text(opsbalance),
                      ),
                    ],
                  );
  
  
                }else if(snapshot.hasError){
                  return new Text(snapshot.error);
                }
  
                //loading the page
                return new Center(
                  child: new CircularProgressIndicator(),
                );
              }),
        ),
      );
  
      return MaterialApp(
        home: Scaffold(
            appBar: AppBar(
              title: Text('${widget.name}'),
            ),
            body: body
        ),
      );
    }
  }
  </code></pre>
  
  <p>This is the error I am running into:</p>
  
  <pre><code>compiler message: lib/Fifth.dart:72:155: Error: The argument type '#lib1::EntitlementsModel' can't be assigned to the parameter type '#lib2::EntitlementsModel'.
  compiler message: Try changing the type of the parameter, or casting the argument to '#lib2::EntitlementsModel'.
  compiler message:                                         new MaterialPageRoute(builder: (context) =&gt; Dep.Dependents(name: user[index].name, entitlementsModel: user[index].entitlements))
  compiler message:
  </code></pre>
  
  <p>and also:</p>
  
  <pre><code>I/flutter ( 6816): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
  I/flutter ( 6816): The following assertion was thrown building FutureBuilder&lt;List&lt;DependantModel&gt;&gt;(dirty, state:
  I/flutter ( 6816): _FutureBuilderState&lt;List&lt;DependantModel&gt;&gt;#bdb2c):
  I/flutter ( 6816): type 'NoSuchMethodError' is not a subtype of type 'String'
  </code></pre>
  
  <p>My question is: </p>
  
  <p>How do I fix the error because its saying I should cast the argument but I do not know how because the <strong>EntitlementsModel</strong> is a class containing multiple classes of Maps. </p>