Short answer
Wrap the string in Uri.parse: http.get(Uri.parse(url)). For URLs you build from parts, use Uri.https(host, path, queryParameters), which also encodes query values for you.
Rather not fix it yourself? App Fix Ticket fixes one reproducible bug at a fixed price, with an optional Diagnosis that is credited toward the fix.
Why a String is rejected, and the fix
01
Code written for package:http before 0.13
“All APIs which previously allowed a String or Uri to be passed now require a Uri.” pub.dev, package:http 0.13.0 changelog
get, post, put, delete and the Client methods all take a Uri now. Convert the string once, at the call.
import 'package:http/http.dart' as http; final response = await http.get(Uri.parse('https://api.example.com/items'));02
A URL built by joining strings
String concatenation breaks on spaces and special characters in query values. Uri.https builds the URL from parts and encodes the query for you; use Uri.http for plain http, such as a local server. Pass the bare host (api.example.com), not https://api.example.com.
final uri = Uri.https('api.example.com', '/search', { 'q': query, 'page': '$page', }); final response = await http.get(uri);03
url_launcher and WebView calls
The same error comes from launchUrl and canLaunchUrl in url_launcher (the old launch took a String) and from WebViewController.loadRequest. Parse the string first.
await launchUrl(Uri.parse(url)); controller.loadRequest(Uri.parse(url));04
A malformed URL string
Uri.parse throws a FormatException for a string that isn’t a valid URI. Use Uri.tryParse for user input, which returns null instead of throwing.
final uri = Uri.tryParse(input); if (uri == null || !uri.hasScheme) { // show a validation error }
Checked against the vendor’s docs on : pub.dev: package:http changelog (0.13.0); Dart API: Uri.parse.
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug. The Fix costs $1,200. If you need a Diagnosis first, its $450 fee counts toward the Fix.See scope and start
- from $450AI-Built App RescueFor a whole-app review, the $450 Launch Check is credited toward the optional $1,950 Rescue Sprint for up to five critical or high findings.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.See scope and start
“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
Related: Flutter “Connection closed before full header” · Flutter “SocketException: Failed host lookup” · Flutter “The parameter can’t have a value of null” · Flutter “can’t be assigned to the parameter type ‘PreferredSizeWidget’”