Skip to content

Instantly share code, notes, and snippets.

@felangel felangel/login_bloc.dart
Last active Oct 14, 2018

What would you like to do?
[bloc_package] LoginBloc
class LoginBloc extends Bloc<LoginEvent, LoginState> {
LoginState get initialState => LoginState.initial();
void onLoginButtonPressed({String username, String password}) {
username: username,
password: password,
Stream<LoginState> mapEventToState(LoginState state, LoginEvent event) async* {
if (event is LoginButtonPressed) {
yield LoginState.loading();
try {
final token = await _authenticate(event.username, event.password);
yield LoginState.success(token);
} catch (error) {
yield LoginState.failure(error.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.