login method Null safety
- dynamic user
Checks credentials and conditionally saves them
Implementation
Future<bool> login(User user) async {
final bool rightCredentials;
try {
rightCredentials = await OpenFoodAPIClient.login(user);
} catch (e) {
throw Exception(e);
}
if (rightCredentials) {
await putUser(user);
notifyListeners();
}
return rightCredentials && await credentialsInStorage();
}