Implementing the MVVM and MVI patterns with flutter_bloc
First of all, what exactly is a bloc? BLoC is an acronym that stands for Business Logic Component. The general idea is very similar to all of the patterns that we have discussed so far, but the tooling and the naming are a bit different. Here, we have the View, which is our widget, we have our Model (also known as the data source), and we have the intermediary, ViewModel, which in the case of this library can be one of two things: a cubit or a bloc.
What is a cubit?
We will learn about both components of this library but we will start with the simpler one – the cubit. Let’s take a look at the following diagram, which showcases its behavior:
Figure 4.7 – Data flow among the Cubit components
Looks eerily familiar, right? That’s because the idea, specifically regarding our implementation up to this point, is pretty much the same. The difference is in the mechanics...