Query Parameter

29 views
Skip to first unread message

Jolaade Oluwadara

unread,
Jan 14, 2022, 11:42:08 AM1/14/22
to Flutter Development (flutter-dev)
Hello I am beginner in flutter I am trying to make a request but a query parameter is required. How do I go about it. Btw the value of the query parameter can be found in the response body of another api call.  Can anyone help, I would appreciate it. Thanks.

adma...@gmail.com

unread,
Jan 15, 2022, 9:17:34 AM1/15/22
to Flutter Development (flutter-dev)
If you Google flutter query parameter then the first link in the top result is to a StackOverflow post that answers your question. I strongly recommend Googling any question you have. It's what professional developers do, I believe ;-)

Here's the code in that answer:

final queryParameters = {
  'param1': 'one',
  'param2': 'two',
};
final uri =
    Uri.https('www.myurl.com', '/api/v1/test/${widget.pk}', queryParameters);
final response = await http.get(uri, headers: {
  HttpHeaders.authorizationHeader: 'Token $token',
  HttpHeaders.contentTypeHeader: 'application/json',
});
Reply all
Reply to author
Forward
0 new messages