I am calling API data and want to show it without using listview.builder in flutter but the error I am facing is that the data is not get loading and the loading indicator is active all the time.

For Example, When I open my app the data get starts loading itself (as I am using future). but it always loads and data didn't get fetched from API.

I am looking for someone who can help me to fix this issue?

For this purpose here is myClass Code.

class _TestState extends State<Test> {
 Future<List<dynamic>> getLiveMatches() async {
 http.Response response = await http.get(
    Uri.parse("https://api.cricket.com.au/matches/2780/50837/live")
 );
 final Map parseData = await json.decode(response.body.toString());
 var matches  = parseData['liveMatch'];
 return matches;
 }

 @override
 Widget build(BuildContext context) {
 return Scaffold(
  body:  Padding(
    padding: EdgeInsets.only(left: 10, right: 10, top: 15),
    child: RefreshIndicator(
      color: Colors.white,
      backgroundColor: Colors.purple,
      strokeWidth: 5,
      onRefresh: ()async{
        getLiveMatches();
      },
      child: Container(
        height: double.infinity,
        decoration: BoxDecoration(
            borderRadius: BorderRadius.only(
                topLeft: Radius.circular(6),
                topRight: Radius.circular(6)
            ),
            color: Colors.white
        ),
        child: FutureBuilder<List<dynamic>>(
            future: getLiveMatches(),
            builder: (context, snapshot) {
              if (snapshot.hasData) {
                List<dynamic> matches = snapshot.data;
                print(matches);
                return Column(
                  children: [
                    Text(matches.toString())
                  ],
                );
              }
              return Center(
                  child: CupertinoActivityIndicator(
                      animating: true, radius: 10));
            }
        ),
      ),
      ),
      ),
     );
     }
     }


Solution 1: Erlend

You are not requesting json. Try: https://api.cricket.com.au/matches/2780/50837/live?format=json

Btw, your onRefresh call does nothing.