I have been trying to debug what is going wrong but the only solution is removing the inTasks.add(res)
because the loop freezes at that point, so is managing data within a Future not allowed in dart/flutter is there a better way to do this, i also get no errors and I've tried uisng global variables with no luck.
Future<List> getWeekly(DateTime date) async {
List inTasks;
for (var i = 0; i < 7; i++) {
var params = {'date': date.toIso8601String()};
Uri uri = Uri.parse('URL');
final newURI = uri.replace(queryParameters: params);
http.Response response = await http.get(
newURI,
headers: {"Accept": "application/json"},
);
var res = json.decode(response.body);
date.add(Duration(days: i));
inTasks.add(res);
return inTasks;
}
}