Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter http 0.13.0 : String can not assign to Uri [duplicate]

I have upgraded http version and getting this type of error.

The argument type 'String' can't be assigned to the parameter type 'Uri'.

Any solution for convert String to Uri?

like image 659
Kalp Shah Avatar asked Mar 06 '21 07:03

Kalp Shah


People also ask

Is it possible to convert string to Uri?

The argument type 'String' can't be assigned to the parameter type 'Uri'. Any solution for convert String to Uri? Show activity on this post. As per the changelog of http, you need to use Uri.

How to resolve HTTP GET Uri is not working error?

So in the await http.get (uri) method the uri is the String variable which holds my server URL. So to solve this error all we have to do is Wrap the uri or the URL into Uri.parse () method.

How to parse URI or URL in await http?

So in the await http.get (uri) method the uri is the String variable which holds my server URL. So to solve this error all we have to do is Wrap the uri or the URL into Uri.parse () method. See the code example below.

How do I set the path component of a URI?

The userInfo, host and port components are set from the authority argument. If authority is null or empty, the created Uri has no authority, and isn't directly usable as an HTTP URL, which must have a non-empty host. The path component is set from the unencodedPath argument. The path passed must not be encoded as this constructor encodes the path.


1 Answers

As per the changelog of http, you need to use Uri.

You can convert Uri using Uri.parse

Uri.parse(your_url);
like image 185
Pratik Butani Avatar answered Oct 18 '22 23:10

Pratik Butani