• Home
  • The argument type string cant be assigned to the parameter type uri flutter – Android

The argument type string cant be assigned to the parameter type uri flutter – Android

In Flutter, you can use the Uri.parse() method to parse a string into a Uri object. You can then pass this Uri object as an argument where a Uri is expected.

For example, if you have a string url that you want to pass as an argument to a method that expects a Uri, you can do the following:

Uri uri = Uri.parse(url);
// pass `uri` as an argument where a `Uri` is expected

Alternatively, you can use the Uri.tryParse() method, which returns a null value if the string cannot be parsed into a Uri. This can be useful if you want to validate the string before attempting to parse it.

Uri uri = Uri.tryParse(url);
if (uri != null) {
// `uri` is a valid `Uri` and can be used as an argument
} else {
// `url` is not a valid `Uri` and cannot be used as an argument
}

I hope this helps! Let me know if you have any further questions.