5

I am writing a function on Flutter, which fetches data from an API. After the function is done, I need to return variable as Future<Response>

Here is the function:

final String apiUrl =  "http://api.aladhan.com/v1/calendarByCity?city=Kayseri&country=Turkey&method=13&month=07&year=2021";

Future<Response> fetchData() async {
 var result = await http.get(Uri.parse(apiUrl));
 return result;
}

However, I get this message from the compiler:

The name 'Response' isn't a type so it can't be used as a type argument.
Try correcting the name to an existing type, or defining a type named 'Response'

Is there any other way to return that variable?

Thank you

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96

1 Answers1

2
Future<http.Response> 

Use http because that's how you imported it.

Huthaifa Muayyad
  • 11,321
  • 3
  • 17
  • 49