Im using Flutter and I´m trying to conect my aplicaction to a database, however I can conect because always appear that error in this sentence (in url):
var response = await http.post(url, body: json.encode(data));
, Does anyone know what the problem is? Here is the code:
class LoginUserState extends State {
// For CircularProgressIndicator.
bool visible = false ;
// Getting value from TextField widget.
final emailController = TextEditingController();
final passwordController = TextEditingController();
Future userLogin() async{
// Showing CircularProgressIndicator.
setState(() {
visible = true ;
});
// Getting value from Controller
String email = emailController.text;
String password = passwordController.text;
// SERVER LOGIN API URL
var url = 'https://fluer-examples.com/login_user.php';
// Store all data with Param Name.
var data = {'email': email, 'password' : password};
// Starting Web API Call.
var response = await http.post(url, body: json.encode(data));
// Getting Server response into variable.
var message = jsonDecode(response.body);
// If the Response Message is Matched.
if(message == 'Login Matched')
{
// Hiding the CircularProgressIndicator.
setState(() {
visible = false;
});
// Navigate to Profile Screen & Sending Email to Next Screen.
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ProfileScreen(email : emailController.text))
);
}else{
// If Email or Password did not Matched.
// Hiding the CircularProgressIndicator.
setState(() {
visible = false;
});
// Showing Alert Dialog with Response JSON Message.
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: new Text(message),
actions: <Widget>[
FlatButton(
child: new Text("OK"),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);}
}