title: Flutter: 'NoSuchMethodError' is not a subtype of type String
body: <p>I currently have an app that pulls a list of providers through JSON.</p>
  
  <p>This is the JSON file.</p>
  
  <p><strong>hospitals.json</strong></p>
  
  <pre><code>{
  "Johor": [
      {
        "Name": "KLINIK TAJ (MUAR)",
        "TPA Customer ID": "1168",
        "Organization Type": "Clinic",
        "Organization Subtype": "GP",
        "Street (Billing)": "35a, jalan abdullah ",
        "City (Billing)": "muar",
        "Postal Code (Billing)": "84000",
        "State (Billing)": "Johor",
        "Country (Billing)": "Malaysia",
        "Coordinates": {
          "Latitude": "2.041875",
          "Longitude": "102.568235"
        }
      },
      {
        "Name": "KLINIK TAJ (PAGOH)",
        "TPA Customer ID": "1169",
        "Organization Type": "Clinic",
        "Organization Subtype": "GP",
        "Street (Billing)": "100 Main Road Pagoh",
        "City (Billing)": "Muar",
        "Postal Code (Billing)": "84600",
        "State (Billing)": "Johor",
        "Country (Billing)": "Malaysia",
        "Coordinates": {
          "Latitude": "2.148342",
          "Longitude": "102.771002"
        }
      }
    ],
    "Kedah": [
      {
        "Name": "KLINIK TAN",
        "TPA Customer ID": "8423",
        "Organization Type": "Clinic",
        "Organization Subtype": "GP",
        "Street (Billing)": "62 Jalan Raya",
        "City (Billing)": "Kulim",
        "Postal Code (Billing)": "9000",
        "State (Billing)": "Kedah",
        "Coordinates": {
          "Latitude": "5.366739",
          "Longitude": "100.553988"
        }
      },
      {
        "Name": "KLINIK SHAN",
        "TPA Customer ID": "1685",
        "Organization Type": "Clinic",
        "Organization Subtype": "GP",
        "Street (Billing)": "L. C. 19, Jalan Lunas,",
        "City (Billing)": "Padang Serai",
        "Postal Code (Billing)": "9000",
        "State (Billing)": "Kedah",
        "Coordinates": {
          "Latitude": "5.402193",
          "Longitude": "100.555209"
        }
      }
    ]
  }
  </code></pre>
  
  <p>This is the model class of the JSON</p>
  
  <p><strong>new_accounts_model.dart</strong></p>
  
  <pre><code>class Johor {
  
    List&lt;AccountInfo&gt; accountinfo;
  
    Johor({this.accountinfo});
  
    factory Johor.fromJson(Map&lt;String, dynamic&gt; json){
  
      var accJson = json["Johor"] as List;
      List&lt;AccountInfo&gt; accList = accJson.map((i) =&gt; AccountInfo.fromJson(i)).toList();
  
      return Johor(
          accountinfo: accList
      );
    }
  }
  
  class AccountInfo{
  
    String name;
    String id;
    String orgtype;
    String subtype;
    String street;
    String city;
    String country;
    Coordinates coordinates;
  
    AccountInfo({this.name, this.id, this.orgtype, this.subtype, this.street, this.city, this.country, this.coordinates});
  
    factory AccountInfo.fromJson(Map&lt;String, dynamic&gt; json){
  
      return AccountInfo(
          name: json["Name"],
          id: json["TPA Customer ID"],
          orgtype: json["Organization Type"],
          subtype: json["Organization Subtype"],
          street: json["Street (Billing)"],
          city: json["City (Billing)"],
          country: json["State (Billing)"],
          coordinates: Coordinates.fromJson(json["Coordinate"])
      );
    }
  }
  
  class Coordinates{
  
    String lat;
    String lng;
  
    Coordinates({this.lat, this.lng});
  
    factory Coordinates.fromJson(Map&lt;String, dynamic&gt; json){
  
      return Coordinates(
          lat: json["Latitude"],
          lng: json["Longitude"]
      );
    }
  }
  </code></pre>
  
  <p>And this is the dart file used to bring out the JSON file.</p>
  
  <p><strong>list.dart</strong></p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:url_launcher/url_launcher.dart';
  import 'dart:async' show Future;
  import 'package:flutter/services.dart' show rootBundle;
  import 'dart:convert';
  import 'package:emas_app/model/new_accounts_model.dart';
  
  Future&lt;String&gt; _loadAsset() async{
    return await rootBundle.loadString('Assets/hospitals.json');
  }
  
  //Not working future
  Future&lt;Johor&gt; loadJohor() async{
  
    final response = await _loadAsset();
    final jsonResponse = json.decode(response);
  
    Johor johor = new Johor.fromJson(jsonResponse);
  
    return johor;
  }
  
  class ProviderList extends StatefulWidget {
  
    @override
    ListState createState() {
      return new ListState();
    }
  }
  
  class ListState extends State&lt;ProviderList&gt; {
  
    @override
    Widget build(BuildContext context) {
  
      List&lt;Widget&gt; widgets = [];
  
      launchMapUrl(String lat, String lng) async{
        String geoUri = "https://maps.google.com/maps?q=loc:$lat,$lng";
        if (await canLaunch(geoUri)) {
          print("Can launch");
          await launch(geoUri);
        } else {
          print("Could not launch");
          throw 'Could not launch Maps';
        }
      }
  
      //method to bring out dialog
      makeDialog(String address){
        showDialog(
            context: context,
            builder: (_) =&gt; new SimpleDialog(
              contentPadding: EdgeInsets.only(left: 30.0, top: 30.0),
              children: &lt;Widget&gt;[
                new Text("Address: $address",
                  style: TextStyle(
                    fontWeight: FontWeight.bold
                  ),
                ),
                new ButtonBar(
                  children: &lt;Widget&gt;[
                    new IconButton(
                        icon: Icon(Icons.close),
                        onPressed: (){
                          Navigator.pop(context);
                        }
                        )
                  ],
                )
              ],
            )
        );
      }
  
      widgets.add(new ExpansionTile(
          title: new Text("Not working state"),
          children: &lt;Widget&gt;[
            new FutureBuilder&lt;Johor&gt;(
                future: loadJohor(),
                builder: (context, snapshot){
                  if(snapshot.hasData){
  
                    return new ListView.builder(
                        shrinkWrap: true,
                        itemCount: snapshot.data.accountinfo.length,
                        itemBuilder: (context, index){
  
                          String username = snapshot.data.accountinfo[index].name;
                          String address = snapshot.data.accountinfo[index].street;
                          String lat = snapshot.data.accountinfo[index].coordinates.lat;
                          String lng = snapshot.data.accountinfo[index].coordinates.lng;
  
                          return new ListTile(
                              title: new Text(username),
                              trailing: new Row(
                                mainAxisSize: MainAxisSize.min,
                                mainAxisAlignment: MainAxisAlignment.end,
                                children: &lt;Widget&gt;[
                                  new IconButton(
                                      icon: Icon(Icons.info),
                                      onPressed: (){
                                        makeDialog(address);
                                      }
                                  ),
                                  new IconButton(
                                      icon: Icon(Icons.directions),
                                      onPressed: (){
                                        launchMapUrl(lat, lng);
                                      }
                                  )
                                ],
                              )
                          );
                        });
                  }else if(snapshot.hasError){
                    return new Center(
                      child: new Text(snapshot.error),
                    );
                  }
                })
          ]
      ));
  
      //empty list
      widgets.add(new ExpansionTile(
          title: new Text("Pahang")));
  
      return new Scaffold(
        appBar: new AppBar(title: new Text("Providers")),
        body: new Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisSize: MainAxisSize.min,
          children: widgets,
        )
      );
    }
  }
  </code></pre>
  
  <p>This is the error currently faced:</p>
  
  <p><a href="https://i.stack.imgur.com/2WANd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2WANd.png" alt="NosuchMethod"></a></p>
  
  <p>As the title says, the error is saying its a NoSuchMethodError. Therefore I am unsure as to what is causing this error in the first place. </p>
  
  <p>My current guess is that I am not doing the Model class correctly but it could be something else.</p>
  
  <p>I could really use some help in this case.</p>