Skip to content

Instantly share code, notes, and snippets.

@VB10
Last active November 23, 2021 00:46
Show Gist options
  • Select an option

  • Save VB10/26e29ddeb12331fb1006cd7ed7dfbdf2 to your computer and use it in GitHub Desktop.

Select an option

Save VB10/26e29ddeb12331fb1006cd7ed7dfbdf2 to your computer and use it in GitHub Desktop.
{
Future<void> controlUser(String email, String password) async {
if (!_changeValidateModel()) return;
_changeLoading();
final response = await loginService.controlUser(model: LoginRequestModel(email: email, password: password));
_changeLoading();
await keepLocalUserResponse(response);
_navigatePage(response);
}
void _navigatePage(UserResponseModel? response) {
if (response != null) {
context.navigateToPage(const WelcomeView());
}
}
bool _changeValidateModel() {
if (formValidateKey.currentState?.validate() ?? false) {
return true;
} else {
_updateAutoValidate(true);
return false;
}
}
Future<bool> keepLocalUserResponse(UserResponseModel? model) async {
if (model != null) {
_loginHiveManager = LoginHiveManager();
await _loginHiveManager.saveModel(model);
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment