-
-
Save boxabirds/aff2c6ac01792c9ace4bb593fa4c9165 to your computer and use it in GitHub Desktop.
Flutter build a GET request with parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How do you make a Flutter HTTP GET request with parameters? | |
// Most examples have no parameters or have parameters embedded in the URL. | |
// This took me hours to find so here we go | |
// no prototcol or slashes | |
// path and parameters are both properly URL encoded. | |
// Uri is part of dart:core | |
import 'package:http/http.dart' as http; | |
// https works the same way. | |
var url = Uri.http("example.org", "/my/service/path", {"getUrlParam1":"value"}); | |
// Inside an async function, you can then pass this to http.get | |
final response = await http.get(url); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you very much