Bloc: Question Regarding Formz package

Created on 1 Jul 2020  路  2Comments  路  Source: felangel/bloc

Hello @felangel, I have gone through flutter_bloc with Formz example and found out a weird thing about the package. Why are we using IsSubmitting and then a IsSubmitted? can't we directly use isSubmitted? Can we just yield isSubmitted directly without any delay?

     if (state.status.isValidated) {
        yield state.copyWith(status: FormzStatus.submissionInProgress);
        await Future.delayed(Duration(milliseconds: 300));
        yield state.copyWith(status: FormzStatus.submissionSuccess);
      }
example question

Most helpful comment

@felangel Thanks this clarifies the issue.

All 2 comments

Hi @jaydangar 馃憢
Thanks for opening an issue!

This is just to illustrate what you might normally do in a real application. In this case you could just yield submissionSuccess but in a real application you would likely make an http request to submit the information the user entered to a backend and await a response which is why it is a two part process (submissionInProgress, submissionSuccess/submissionFailure).

Sorry for the confusion and hope that helps clarify things! 馃憤

@felangel Thanks this clarifies the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rsnider19 picture rsnider19  路  3Comments

MahdiPishguy picture MahdiPishguy  路  3Comments

nerder picture nerder  路  3Comments

abinvp picture abinvp  路  3Comments

ricktotec picture ricktotec  路  3Comments