title: How to implement listview from nested json data using http request in flutter?
body: <p>I am new in flutter. i want to using http request for nested json data and want to show that data in listview. i made http request for get data. and i got 200. but problem is how to return my response for nested json data and show these data to listview? i read many documents but not properly understood. can anyone teach me how to implement this and if i made any wrong, what kind of wrong?</p>
  <p>from json i also want to show &quot;count&quot;, &quot;idEmployee&quot;, &quot;fullname&quot; in my listview.</p>
  <p>N.B: this api and token is just for test purpose.</p>
  <p><strong>Nested Json Data</strong></p>
  <pre><code>{
      &quot;success&quot;: true,
      &quot;data&quot;: {
          &quot;count&quot;: 261,
          &quot;data&quot;: [
              {
                  &quot;idEmployee&quot;: 3588,
                  &quot;avatar&quot;: null,
                  &quot;fullName&quot;: &quot;Moodle Connection Test&quot;,
                  &quot;officeID&quot;: &quot;1003588&quot;,
                  &quot;email&quot;: &quot;&quot;,
                  &quot;designation&quot;: &quot;Senior Executive&quot;,
                  &quot;department&quot;: &quot;Accounts&quot;,
                  &quot;mobileNumber&quot;: &quot;&quot;,
                  &quot;workStation&quot;: &quot;Work Station 12&quot;,
                  &quot;businessUnit&quot;: &quot;CDA&quot;
              }
          ],
      }
  }
  </code></pre>
  <p><strong>ListAlbum Model Class</strong></p>
  <pre><code>class ListAlbum {
    final int? idEmployee;
    final String? avatar;
    final String? fullName;
    final String? officeID;
    final String? email;
    final String? designation;
    final String? department;
    final String? mobileNumber;
    final String? workStation;
    final String? businessUnit;
  
    ListAlbum({
      this.idEmployee,
      this.avatar,
      this.fullName,
      this.officeID,
      this.email,
      this.designation,
      this.department,
      this.mobileNumber,
      this.workStation,
      this.businessUnit,
    });
  
    factory ListAlbum.fromJson(Map&lt;String, dynamic&gt; json) {
      return ListAlbum(
        idEmployee: json['idEmployee'],
        avatar: json['avatar'],
        fullName: json['fullName'],
        officeID: json['officeID'],
        email: json['email'],
        designation: json['designation'],
        department: json['department'],
        mobileNumber: json['mobileNumber'],
        workStation: json['workStation'],
        businessUnit: json['businessUnit'],
      );
    }
  }
  </code></pre>
  <p><strong>Api Calling</strong></p>
  <pre><code>Future&lt;List&lt;ListAlbum&gt;&gt; listData() async {
      final response = await http.post(
        Uri.parse('https://portal-api.jomakhata.com/api/getOrganizationData'),
        headers: {
          'Content-Type': 'application/json',
          'Accept': '*/*',
          'Authorization':
          'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjI4OTksImlzcyI6Imh0dHBzOi8vcG9ydGFsLWFwaS5qb21ha2hhdGEuY29tL2FwaS9hdXRoL2xvZ2luIiwiaWF0IjoxNjMxNDYyNTE3LCJleHAiOjE2MzE1NDg5MTcsIm5iZiI6MTYzMTQ2MjUxNywianRpIjoiY2tXUVAya3RsdEJvTHd4QyJ9.9wkcg2n6XgWC1lAj2ZAwHJFMZIVbtg7cmo_jUN86rBo',
        },
        body: jsonEncode(&lt;String, String&gt;{
          'limit': 5.toString(),
          'orderBy': 'idEmployee',
          'orderType': 'DESC'
        }),
      );
  
      if (response.statusCode == 200) {
        print(response.statusCode);
        print(&quot;ok&quot;);
        print(response.body);
  
        return    // here how to return for nested json data?
  
      } else {
        throw Exception('Failed to create album.');
      }
  }
  </code></pre>
  <p><strong>List View</strong></p>
  <pre><code>void main() {
    runApp(const MyApp());
  }
  
  class MyApp extends StatefulWidget {
    const MyApp({Key? key}) : super(key: key);
  
    @override
  
        _MyAppState createState() {
          return _MyAppState();
        }
      }
      
      class _MyAppState extends State&lt;MyApp&gt; {
        late Future&lt;List&lt;ListAlbum&gt;&gt; futureAlbum;
      
        @override
        void initState() {
          super.initState();
          futureAlbum = listData();
        }
      
        @override
        Widget build(BuildContext context) {
          return MaterialApp(
            title: 'Create Data Example',
            theme: ThemeData(
              primarySwatch: Colors.blue,
            ),
            home: Scaffold(
              body: Center(
                child: FutureBuilder&lt;List&lt;ListAlbum&gt;&gt;(
                  future: futureAlbum,
                  builder: (context, snapshot) {
                    if (snapshot.hasData) {
                      print(snapshot.data);
                      return ListView.builder(
                        itemCount: snapshot.data!.length,
                        itemBuilder: (context, index) {
                          final ListAlbum item = snapshot.data![index];
                          return ListTile(
                            title: Text(item.fullName!),
                            subtitle: Text(item.designation!),
                          );
                        },
                      );
                    } else if (snapshot.hasError) {
                      return Text('${snapshot.error}');
                    }
                    return const CircularProgressIndicator();
                  },
                ),
              ),
            ),
          );
        }
      }
      
  </code></pre>