Skip to content

Instantly share code, notes, and snippets.

@boxabirds
Last active March 16, 2024 04:48
Show Gist options
  • Save boxabirds/aff2c6ac01792c9ace4bb593fa4c9165 to your computer and use it in GitHub Desktop.
Save boxabirds/aff2c6ac01792c9ace4bb593fa4c9165 to your computer and use it in GitHub Desktop.
Flutter build a GET request with parameters
// 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);
@chaghen
Copy link

chaghen commented Oct 11, 2021

thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment