Published on 11th Apr 2021
Capt Compass E1 - cleaning up the codebase
A lot has happened since the latest devlog. Almost a year passed without an update. The pandemic and switching job kept my focus away from my side project, but I am finally back and keep pushing the limits. No new or left behind the project as promised! So let's just jump in the code see what needs to change under the hood!
The initial code started without knowing exactly which state management fits my needs better, to be honest, I was experimenting a lot. So much so that it felt I was wasting too much time discovering the best solution. I understood the existing state management in the community better but things were not progressing and the app flooded with costume solutions. Each screen in my small app had either custom state management or handling the database in the wrong places. Something had to be done and maybe this is just the right time to do so.
removing dead weight
Different state management implementations for each screen troubled me for a long time. I was not confident enough to open a screen and know instantly how I can modify it. I always had to think before coding but they never made big challenges enough to modify them so I just kept them around.
With Flutter 2 on the horizon and null safety Dart, it became clear that I have to get rid of these experimentations otherwise I have to manually upgrade them for null safety. To be able to do that I should have to read the docs and understand the introduction of null safety for each lib. After a few initial try, I decided that there is not much benefit of wasting my time in docs but I would rather get rid of them while I am not committed more.
removing Bloc and Rx
lib was on my list to purge from the codebase. It might be an elegant solution but did not enjoy working with the lib. It was just too much boilerplate for even the smallest code change. While some of the stuff could be eliminated with
I decided to simply ditch the lib.
How hard could it be to get rid of state management? Good thing you ask, it was a pretty much okay experience, the hardest part was getting the right providers for the correct places and fighting with nullability. Overall I was quite pleased how much code I was able to get rid of just removing the
also could be eliminated from the codebase replaced most of the places with
, only a few parts of the API required
dependency which I am super pleased with.
Good progress on both the codebase and now I feel confident to change the codebase on every screen without finding an unexpected pattern that I have to think about how to change.