Skip to content

Instantly share code, notes, and snippets.

@felangel
Last active November 5, 2020 11:57
Show Gist options
  • Save felangel/43c4f66a42c859f27a5823c22e006e0c to your computer and use it in GitHub Desktop.
Save felangel/43c4f66a42c859f27a5823c22e006e0c to your computer and use it in GitHub Desktop.
[bloc_package] LoginState
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