Member-only story
Flutter Cubit Best Practice | flutter_bloc & Firebase Authentication — Tutorial
In this tutorial I will show you how to create a user with Firebase Authentication using email and password together with Cubit found in the flutter_bloc plugin. In tutorial 2, I will show the full authentication flow including sign-in and auth state change handling.
I came across Cubit a while ago which really helped me reduce code and files by a-lot, compared to Bloc. In previous Android projects I used MVC and MVVM architecture for organising my code. These architectures are somewhat difficult to implement in Flutter if no plugins are to be used. Also, Flutter handles state changes in the Widget which is different from what I was used to in Android, and it can be a bit messy. However, Cubit seems to provide a smart way of separating my Business logic and State changes from the Widget code, and I want to show you how it’s done.
Please have an open mind when reading this article, and take it with a pinch of salt. This might not be the best approach of using Cubit, however my goal is to share my knowledge as a professional app developer, I myself am learning every day. I hope you can give a constructive feedback in the comment section, wether you think there might be a better solution or not, I’ll be happy to know. 🙂