The error message “The argument type ‘String’ can’t be assigned to the parameter type ‘Uri'” is indicating that you are passing a String
type to a function or method that expects an Uri
type. In Dart, Uri
is a class used to represent URLs, and it has its own specific methods and properties.
To resolve this error, you need to convert your String
to an Uri
before passing it to the function or method that expects an Uri
type. This can be done using the Uri.parse()
method:
String urlString = "http://example.com";
Uri uri = Uri.parse(urlString);
Now you can pass uri
as an argument where an Uri
type is expected. For example:
await http.get(uri);
This will call the get
method on an http
object and pass it the Uri
type, which is expected by the method.