We will begin by implementing the UserCubit, which manages the user state. The application listens to this state, showing the login screen if the user is logged out and displaying the home screen if the user is logged in.

Cubits, like Blocs, have states. We generate these states in the same way as Bloc states. The only difference between Cubits and Blocs is that instead of listening to event streams, we define functions that can be called within our code.

UserState

The UserCubit will emit several states, all of which extend the UserState abstract class.

Get hands-on with 1200+ tech skills courses.