Last active
November 23, 2021 00:46
-
-
Save VB10/26e29ddeb12331fb1006cd7ed7dfbdf2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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<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