Home > Software engineering >  Flutter Bloc: Many states within a screen, how to handle?
Flutter Bloc: Many states within a screen, how to handle?

Time:04-28

Is it normal for me to give different states from different blocs/cubits within a screen?

For example: on one screen I have two textfields - email and password.

Email textfield has EmailBloc and there is a state to get the value of the textfield.

Password textfield has PasswordBloc and there is a state to get the value of the textfield.

The password textfield has a show/hide password button. The show/hide password button has a ShowPasswordCubit to change its state.

Thank you. I'm a bit confuse using bloc in flutter.

CodePudding user response:

Learning by example is always a good way to go, this got me on my feet with BLoC as well as this.

Essentially, your login page should house the main BLoC where you can pass in the email and pass values via the TextEditingController instead of having a separate BLoC for every textfield/widget.

  • Related