Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created April 9, 2020 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/90c130f9ed7d78b05a4ff10f9182d905 to your computer and use it in GitHub Desktop.
Save parzibyte/90c130f9ed7d78b05a4ff10f9182d905 to your computer and use it in GitHub Desktop.
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