Skip to content

Instantly share code, notes, and snippets.

@VB10
Last active June 27, 2019 19:07
Show Gist options
  • Save VB10/eb2accab456bd58e96bdeb539906acc7 to your computer and use it in GitHub Desktop.
Save VB10/eb2accab456bd58e96bdeb539906acc7 to your computer and use it in GitHub Desktop.
/// The service responsible for networking requests
class Api {
final _client = new http.Client();
Future signin_user(LoginRequest login) {
Completer _completer = new Completer();
_client
.post(
'${ApiHelper.AUTH_END_POINT}/verifyPassword?key=${ApiHelper.API_KEY}',
body: login.toJson())
.then((val) {
final body = json.decode(val.body);
switch (val.statusCode) {
case 200:
_completer.complete(LoginResponse.fromJson(body));
return;
case 400:
_completer.completeError(ErrorFirebaseModel.fromJson(body));
return;
}
});
return _completer.future;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment