title: Flutter http stuck
body: <p>I am sending an API request to return a list of widgets. But it doesn't return anything. I created a model, http service, and a Future builder to return.
  my code:
  my services file:</p>
  <blockquote>
  <p>service.dart</p>
  </blockquote>
  <pre><code>import 'dart:convert';
  import 'package:http/http.dart';
  import '../models/models.dart';
  
      class CardsService {
        final String url = &quot;xxx.com/xx.php&quot;;
      
        
      
          Future&lt;List&lt;Cards&gt;&gt; getCards() async {
              Response res = await get(url);
          
              if (res.statusCode == 200) {
                List&lt;dynamic&gt; body = jsonDecode(res.body);
          
                List&lt;Cards&gt; card = body
                    .map(
                      (dynamic item) =&gt; Cards.fromJson(item),
                    )
                    .toList();
          
                return card;
              } else {
                throw &quot;Can't get Cards.&quot;;
              }
            }
          }
  </code></pre>
  <p>my model file:</p>
  <blockquote>
  <p>model.dart</p>
  </blockquote>
  <pre><code>import 'package:flutter/foundation.dart';
  
  class Cards {
    final String country;
    final String type;
    final int value;
    final String percentage;
    final String sign;
  
    Cards(
        {
        @required this.country,
        @required this.type,
        @required this.value,
        @required this.percentage,
        @required this.sign
        }
        );
  
    factory Cards.fromJson(Map&lt;String, dynamic&gt; json) {
      return Cards(
        country: json['country'] as String,
        type: json['type'] as String,
        value: json['value'] as int,
        percentage: json['percentage'] as String,
        sign: json['sign'] as String,
      );
    }
  }
  </code></pre>
  <p>my main file:</p>
  <blockquote>
  <p>main.dart</p>
  </blockquote>
  <pre><code>import 'package:flutter/material.dart';
  
  import '../models/models.dart';
  import '../services/cards.dart';
  
  
  class CardsWidget extends StatelessWidget {
    final CardsService cardsService = CardsService();
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(&quot;Posts&quot;),
        ),
        body: FutureBuilder(
          future: cardsService.getCards(),
          builder: (BuildContext context, AsyncSnapshot&lt;List&lt;Cards&gt;&gt; snapshot) {
            if (snapshot.hasData) {
              List&lt;Cards&gt; cards = snapshot.data;
              return ListView(
                children: cards
                    .map(
                      (Cards cards) =&gt; ListTile(
                        title: Text(cards.value.toString()),
                        subtitle: Text(&quot;${cards.sign}&quot;),
                        onTap:null ,
                      ),
                    )
                    .toList(),
              );
            } else {
              return Center(child: CircularProgressIndicator());
            }
          },
        ),
      );
    }
  }
  </code></pre>
  <p>but it returns nothing than the CircularProgressIndicator(){i waited so much but it did not show anything, no error and I ran flutter doctor. Everything is ok}), this is my JSON:</p>
  <pre><code>  {
      &quot;country&quot;: &quot;lebanon&quot;,
      &quot;type&quot;: &quot;sell&quot;,
      &quot;value&quot;: &quot;8100&quot;,
      &quot;updated&quot;: &quot;الأحد ٢٩ - نوفمبر - ٢٠٢٠   ٠٧:٣٣ مساءً&quot;,
      &quot;percentage&quot;: &quot;0.3%&quot;,
      &quot;sign&quot;: &quot;decreased&quot;
    },
    {
      &quot;country&quot;: &quot;lebanon&quot;,
      &quot;type&quot;: &quot;buy&quot;,
      &quot;value&quot;: &quot;8175&quot;,
      &quot;updated&quot;: &quot;الأحد ٢٩ - نوفمبر - ٢٠٢٠   ٠٧:٣٣ مساءً&quot;,
      &quot;percentage&quot;: &quot;0%&quot;,
      &quot;sign&quot;: &quot;increased&quot;
    },
    {
      &quot;country&quot;: &quot;syria&quot;,
      &quot;type&quot;: &quot;sell&quot;,
      &quot;value&quot;: &quot;2560&quot;,
      &quot;updated&quot;: &quot;اليوم&quot;,
      &quot;percentage&quot;: &quot;1%&quot;,
      &quot;sign&quot;: &quot;decreased&quot;
    },
    {
      &quot;country&quot;: &quot;syria&quot;,
      &quot;type&quot;: &quot;buy&quot;,
      &quot;value&quot;: &quot;2590&quot;,
      &quot;updated&quot;: &quot;اليوم&quot;,
      &quot;percentage&quot;: &quot;1%&quot;,
      &quot;sign&quot;: &quot;decreased&quot;
    }
  ]
  </code></pre>