Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3630

How to solve connect PHP API with flutter app error

$
0
0

My problem is somewhat strange. I made a PHP API to work on flutter app and unfortunately it does not work. I tried another one and it worked on the web after disabling web protection. Sometimes it also does not work, but it does not work on Android and I do not know where the problem is. Is it in xampp or is there a setting that must be activated?

This is one of them and the easiest:

  Future<void> insertOpreation() async   {    if (name.text != "" || email.text != "" || university.text != "")     {      try       {        String uri = "http://localhost/dashboard/demo/insert.php";        var res = await http.post(Uri.parse(uri), body: {"name" : name.text,"email" : email.text,"university" : university.text        });        var response = jsonDecode(res.body);        if (response["success"] == "true")         {          print("Inserted Successfully");        }        else        {          print("Some Isssue");        }      }       catch (e)       {      }    }    else    {      print("Please fill all fields");    }  }

I tried a lot of uri like as:
10.0.2.2, 10.0.2.2:8000, 127.0.0.1,the ip from ip config


Viewing all articles
Browse latest Browse all 3630

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>