signInUser function
Sign-in existing user with email
and password
Implementation
Future<String> signInUser(String email, String password) async {
try {
var response = await http.post(signInApi,
body: json.encode({
AppConstants.EMAIL: email,
AppConstants.PASSWORD: password,
"returnSecureToken": true
}));
if (response.statusCode == 200) {
Map map = json.decode(response.body);
Utils.loginToken = map['idToken'];
Utils.userId = map['localId'];
return Utils.loginToken;
} else {
Map map = json.decode(response.body);
throw (UserMessageException(map['error']['message']));
}
} catch (err) {
throw err;
}
}