-1
bool _login;
Future<bool> login(String email, String senha) async {
var response = await http.get("http://192.168.0.116:5001/usuarios/login/$email/$senha");
if(response.statusCode == 200) {
return _login = true;
} else {
return _login = false;
}
}
Knob:
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
color: HotelAppTheme.buildLightTheme().primaryColor,
onPressed: () {
logar();
_login == true ? print('s') : print('n');
},
child: Text('Entrar', style: TextStyle(
fontSize: SizeConfig.of(context).dynamicScaleSize(size: 18),
color: Colors.white
),
),
);
If I enter a valid email and password and click on the button, I have as return "s"
, so far everything working as expected, however, if I change and put an invalid email or password, and click the button again, the return is still "s"
, but if I click the button again, the return changes to "n"
as expected. Why in the first action it does not update?
I thank anyone who can help me.
You can take a look here at my answer about async x await x Future to understand a little more about asynchronous functions.
– Matheus Ribeiro