# Flutter: “The argument type ‘String’ can’t be assigned to the parameter type ‘Uri’”

> The argument type String can’t be assigned to the parameter type Uri: package:http takes a Uri. Wrap the URL in Uri.parse, or build it with Uri.https.

Canonical: https://app369.com/fix/flutter-string-cant-be-assigned-to-uri/
Last updated: 2026-11-08

A call like http.get('https://api.example.com/items') fails to compile with The argument type ‘String’ can’t be assigned to the parameter type ‘Uri’. Since version 0.13.0, package:http accepts only a Uri for the URL, so code and tutorials written for older versions break after an upgrade.

**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.

## **Why a String is rejected, and the fix**

1. 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**](https://pub.dev/packages/http/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'));
```
2. 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);
```
3. 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));
```
4. 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 November 8, 2026: [pub.dev: package:http changelog (0.13.0)](https://pub.dev/packages/http/changelog); [Dart API: Uri.parse](https://api.dart.dev/dart-core/Uri/parse.html).

## **Rather hand it over?**

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

- [from $450**App Fix Ticket**One reproducible bug in an existing mobile or web app, diagnosed and fixed.**See scope and start**](https://app369.com/fixed-price/flutter-firebase-bug-fix/)
- [from $450**AI-Built App Rescue**A Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.****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**](https://app369.com/fixed-price/ai-app-rescue/)

Related: [**Flutter “Connection closed before full header”**](https://app369.com/fix/flutter-httpexception-connection-closed-before-full-header/) · [**Flutter “SocketException: Failed host lookup”**](https://app369.com/fix/flutter-socketexception-failed-host-lookup/) · [**Flutter “The parameter can’t have a value of null”**](https://app369.com/fix/flutter-parameter-cant-have-a-value-of-null/) · [**Flutter “can’t be assigned to the parameter type ‘PreferredSizeWidget’”**](https://app369.com/fix/flutter-cant-be-assigned-to-preferredsizewidget/)

Questions

## **More on this error**

<details>

<summary>**Should I pin http to an old version instead? **+</summary>

No. Versions before 0.13 aren’t null safe, so current Dart rejects them. Changing each call to Uri.parse is a quick, mechanical fix.

</details>

<details>

<summary>**Does Dio have the same rule? **+</summary>

No, Dio accepts a String path. This error comes from package:http, url_launcher, WebView and other APIs whose parameter type is Uri.

</details>

<details>

<summary>**Can you fix it for me? **+</summary>

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. 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.

</details>

A different error?

## **Describe it and get a written quote**

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.

[**Describe your problem **→](https://app369.com/contact/) [**All fixes**](https://app369.com/fix/)