when I use try and catch to use API insert opreation and the opreation inserted successfully but unfortunately the toast message don’t print “signed up successfully”, it print this “Error: ClientException: XMLHttpRequest error., uri=”http://localhost/dashboard/help_me/signup.php” “
<code> Future<void> SignupClient() async {
if (name.text!= "" || phone.text!= "") {
try {
var res = await http.post(
Uri.parse(ApisConnect.signupApi),
body:
{
"name": name.text,
"phone": phone.text,
}
);
var response = jsonDecode(res.body);
if (response["success"] == true) {
Fluttertoast.showToast(msg: 'signed up successfully');
} else if (response["success"] == false) {
Fluttertoast.showToast(msg: 'try again');
}
} catch (e) {
Fluttertoast.showToast(msg: 'Error $e');
}
}
}
</code>
<code> Future<void> SignupClient() async {
if (name.text!= "" || phone.text!= "") {
try {
var res = await http.post(
Uri.parse(ApisConnect.signupApi),
body:
{
"name": name.text,
"phone": phone.text,
}
);
var response = jsonDecode(res.body);
if (response["success"] == true) {
Fluttertoast.showToast(msg: 'signed up successfully');
} else if (response["success"] == false) {
Fluttertoast.showToast(msg: 'try again');
}
} catch (e) {
Fluttertoast.showToast(msg: 'Error $e');
}
}
}
</code>
Future<void> SignupClient() async {
if (name.text!= "" || phone.text!= "") {
try {
var res = await http.post(
Uri.parse(ApisConnect.signupApi),
body:
{
"name": name.text,
"phone": phone.text,
}
);
var response = jsonDecode(res.body);
if (response["success"] == true) {
Fluttertoast.showToast(msg: 'signed up successfully');
} else if (response["success"] == false) {
Fluttertoast.showToast(msg: 'try again');
}
} catch (e) {
Fluttertoast.showToast(msg: 'Error $e');
}
}
}
I tried to remove try and catch or change this