Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Future<bool> login(String usuario, String password) async {
setState(() {
cargandoBoton = true;
});
final http.Response response = await http.post(
rutaLogin,
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
body: jsonEncode(<String, String>{
'email': usuario,
'password': password,
}),
);
setState(() {
this.cargandoBoton = false;
});
if (response.statusCode == 200) {
Map<String, dynamic> respuesta = json.decode(response.body);
var token = respuesta["access_token"];
await _guardarToken(token);
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.