BLoC
Last modified on Wed 27 Jan 2021

We use bloclibrary. Please, make sure you read their short introduction guide. It is well written and explains problem why you need such a solution.

Freezed in Bloc

We see some great benefits of using freezed for bloc events and states. Events will always be shaped like a sealed classes, so it's neat to write something like PaymentEvents. and you'll see autocomplete of all event options. On the consuming side, in the bloc, you have a neat event.when method so you can call appropriate methods for each event.

Another advantage is copyWith. This is useful if you have a bloc state. If your state changes a lot, then you have possibility to change just one property of the state, like state.copyWith(submitEnable = true) while keeping immutability. Without freezed this would look much uglier.