Created
April 9, 2020 19:48
-
-
Save parzibyte/90c130f9ed7d78b05a4ff10f9182d905 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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