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?
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.
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.
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.
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.
As per the changelog of http, you need to use Uri.
You can convert Uri using Uri.parse
Uri.parse(your_url);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With