I have an API and I need to put non-optional parametrs in GET-request and I did this:
Future<List<FlightBook>> fetchFlights(int mv_id) async {
String basicAuth =
'Basic ' + base64Encode(utf8.encode('$username:$password'));
print(basicAuth);
final queryParameters = {
"mv_id" : mv_id,
};
var response = await http.get(Uri.parse("http:/mylink/getFlights.php?fmt=json&{$queryParameters}" ), headers: <String, String>{'authorization': basicAuth});
var jsonResponse = convert.jsonDecode(response.body) as List;
return jsonResponse.map((e) => FlightBook.fromJson(e)).toList();
}
but when I tried to get some data from this I got the blank screen with no values and after that I did request like so and everything works fine:
'var response = await http.get(Uri.parse("http:/mylink/getFlights.php?fmt=json&mv_id=1'
How can I put this parametr inside my link if I need not only the first elemnt but all elements?