I am having a problem woth my code when connecting API's in flutter does anyone know how I can solve this error?
import 'package:ctrade/constants/strings.dart';
import 'package:ctrade/models/Users.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
class Services {
static const String url = 'https://linkhere.co.zw';
static Future<List<Markets>> getMarkets() async{
try{
final response = await http.get(Uri.parse(url));
if(200 == response.statusCode) {
final List<Markets> markets = marketsFromJson(response.body);
return markets;
}else {
return List<Markets>(); //error here
}
}catch(e){
return List<Markets>(); //error here
}
}
}