title: Parse complex JSON In flutter and type 'Future<dynamic>' is not a subtype of type 'Future<AllUsers>'
body: <p>I'm just parsing complex JSON and display on listView for learning purpose.</p>
  
  <blockquote>
    <p><strong>API:</strong>  <a href="https://jsonplaceholder.typicode.com/users" rel="nofollow noreferrer">https://jsonplaceholder.typicode.com/users</a></p>
  </blockquote>
  
  <p><strong>1) Model Class</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>class AllUsers {
    final List&lt;User&gt; alluser;
  
    AllUsers({this.alluser});
  
    factory AllUsers.formJson(List&lt;dynamic&gt; jsonArr){
      List&lt;User&gt; arruser = jsonArr.map((f)=&gt; User.formJson(f)).toList();
      return AllUsers(
        alluser:  arruser
      );
    }
  }
  class User {
    int id;
    String name;
    String email;
    Address address;
    String phone;
    String website;
    Company company;
  
    User({this.id, this.name, this.email, this.address, this.phone, this.website, this.company});
  
    factory User.formJson(Map&lt;String, dynamic&gt; jsonObj) {
      return User(
        id: jsonObj['id'],
        name: jsonObj['name'],
        email: jsonObj['email'],
        address: Address.formJson(jsonObj['address']),
        phone: jsonObj['phone'],
        website: jsonObj['website'],
        company: Company.formJson(jsonObj['company'])
      );
    }
  } 
  class Address {
    String street;
    String suite;
    String city;
    String zipcode;
    Geo geo;
  
    Address({this.street, this.suite, this.city, this.zipcode, this.geo});
  
    factory Address.formJson(Map&lt;String, dynamic&gt; jsonObj) {
      return Address(
        street: jsonObj['street'],
        suite: jsonObj['suite'],
        city: jsonObj['city'],
        zipcode: jsonObj['zipcode'],
        geo: Geo.formJson(jsonObj['geo'])
      );
    }
  } 
  class Geo {
    String lat;
    String lng;
  
    Geo({this.lat, this.lng});
  
    factory Geo.formJson(Map&lt;String, dynamic&gt; jsonObj) {
      return Geo(
        lat: jsonObj['lat'],
        lng: jsonObj['lng'],
      );
    }
  } 
  class Company {
    String name;
    String catchPhrase;
    String bs;
  
    Company({this.name, this.catchPhrase, this.bs});
  
    factory Company.formJson(Map&lt;String, dynamic&gt; jsonObj) {
      return Company(
        name: jsonObj['name'],
        catchPhrase: jsonObj['catchPhrase'],
        bs: jsonObj['bs']
      );
    }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>2)ViewModel</strong> </p>
  
  <pre><code>import 'package:http/http.dart' as http;
  import 'dart:convert';
  import 'dart:async';
  import 'package:parsejsonlist/All Screens/Home/Model/users.dart';
  
  class UserViewModel {
    Future&lt;AllUsers&gt; callWebserviceForFetchUserData() async{
      var listOfUser = await http.get('https://jsonplaceholder.typicode.com/users');
      List&lt;User&gt; decodedJSON = json.decode(listOfUser.body);
      AllUsers arrayOfAlluser = AllUsers.formJson(decodedJSON);
      print("arrayOfAlluser $arrayOfAlluser");
      return arrayOfAlluser;
    }
  }
  </code></pre>
  
  <p><strong>3) View Portion of the code.</strong></p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:parsejsonlist/All Screens/Home/Model/users.dart';
  import 'package:parsejsonlist/All Screens/Home/ModelView/userviewmodel.dart';
  
  class HomeSceen extends StatefulWidget {
    @override
    State&lt;StatefulWidget&gt; createState() =&gt; HomeScreenState();
  }
  
  class HomeScreenState extends State&lt;HomeSceen&gt; {
  
    AllUsers arryOfUser;
    UserViewModel userViewmodel;
  
    @override 
    initState(){
      super.initState();     
      userViewmodel = UserViewModel();
    }
  
    callMethodFetchUserData() async {
      arryOfUser = await userViewmodel.callWebserviceForFetchUserData();
      User userRes =  arryOfUser.alluser[0];
      print("response === &gt;&gt; ${userRes.company.catchPhrase}");
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text("JSON Parsing")
        ),
        body: Container(
          child: FutureBuilder&lt;AllUsers&gt;(
            future: callMethodFetchUserData(),
            builder: (context, data){
              return setupListView();
            },          
          ),
        ),
      );
    }
  
    Widget setupListView(){
    return ListView.builder(
      itemCount: arryOfUser.alluser.length,
      itemBuilder: (BuildContext context, int index) {
        User userdata = arryOfUser.alluser[index];
        setupListTile(userdata);
      },
    );
   }
  
  
  
      Widget setupListTile(User userdata){
    return ListTile(
      leading: CircleAvatar(
        backgroundColor: Colors.orangeAccent,
        child: Text(userdata.name[0].toUpperCase(), 
        style: TextStyle(color: Colors.white)),
      ),
      title: Text(userdata.name),
      subtitle: Text(userdata.company.name),    
    );
   }
  }
  </code></pre>
  
  <p>So, My question is each time i'm getting fail with so many error like.</p>
  
  <blockquote>
    <p>type 'Future' is not a subtype of type 'Future'</p>
  </blockquote>
  
  <p>I know there are so many mistake but I'm new to Flutter.
  Where i'm going wrong? How to solve this issue please guide me on right direction. </p>
  
  <p><strong>UPDATED</strong></p>
  
  <pre><code>child: FutureBuilder&lt;List&lt;User&gt;&gt;(
            future: userViewmodel.callWebserviceForFetchUserData(),
            builder: (BuildContext context, AsyncSnapshot&lt;List&lt;User&gt;&gt; snapshot) {
              switch (snapshot.connectionState) {
                case ConnectionState.none:
                  return Text('Press button to start.');
                case ConnectionState.active:
                case ConnectionState.waiting:
                  return Text('Awaiting result...');
                case ConnectionState.done:
                  if (snapshot.hasError) return Text('Error: ${snapshot.error}');
                  return setupListView(snapshot.data);
              }
              return null;
            },
  
  Getting Error: "Type List&lt;dynamic&gt; is not a subtype of type List&lt;User&gt;"
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/BnMBr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BnMBr.png" alt="enter image description here"></a></p>
  
  <p>Is there any mistake in model class ?</p>