Skip to content
Advertisement

The argument type ‘String’ can’t be assigned to the parameter type ‘Uri’. Flutter

I’m having a trouble, why I’m getting this error in my app flutter main.dart I just follow this reference link. It would be great if anybody could figure out, thank you so much in advance!.

Here’s the error part

Future<List> _login() async {
   final response = await http.post("http://10.0.2.2/my_store/login.php", body: {
      "username": user.text,
      "password": pass.text,
 });

enter image description here

Advertisement

Answer

You need to parse your URLs now, use it like this:

Future<List> _login() async {
   final response = await http.post(Uri.parse("http://10.0.2.2/my_store/login.php"), body: {
      "username": user.text,
      "password": pass.text,
 });
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement