Last active
November 5, 2020 11:57
-
-
Save felangel/43c4f66a42c859f27a5823c22e006e0c to your computer and use it in GitHub Desktop.
[bloc_package] LoginState
This file contains 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
class LoginState { | |
final bool isLoading; | |
final bool isLoginButtonEnabled; | |
final String error; | |
final String token; | |
const LoginState({ | |
@required this.isLoading, | |
@required this.isLoginButtonEnabled, | |
@required this.error, | |
@required this.token, | |
}); | |
factory LoginState.initial() { | |
return LoginState( | |
isLoading: false, | |
isLoginButtonEnabled: true, | |
error: '', | |
token: '', | |
); | |
} | |
factory LoginState.loading() { | |
return LoginState( | |
isLoading: true, | |
isLoginButtonEnabled: false, | |
error: '', | |
token: '', | |
); | |
} | |
factory LoginState.failure(String error) { | |
return LoginState( | |
isLoading: false, | |
isLoginButtonEnabled: true, | |
error: error, | |
token: '', | |
); | |
} | |
factory LoginState.success(String token) { | |
return LoginState( | |
isLoading: false, | |
isLoginButtonEnabled: true, | |
error: '', | |
token: token, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment