Showing My Work #02

Showing My Work #02
Photo by Fons Heijnsbroek / Unsplash

Welcome to 2025, officially. At my house, we’ve taken down all of the Christmas lights, put away all the new things (mostly), and we’ve started making plans for 2025.

Making My Flutter App Production-Worthy Starting with the Architecture

I'm currently working on making my mobile app, Geml, ready for prime time. My main goal is to have all of my code covered by tests, especially unit tests. I also want to learn the best way to structure my future apps.

The biggest hurdle has been figuring out how to properly test all the different parts of my app. I use the flutter_bloc library for state management, but I've been having trouble finding a good, consistent testing approach.

My research on Flutter testing led me to realize that the app's architecture plays a big role in how you test it. I found a really helpful blog post on the Code with Andrea website that explained why I was struggling with testing – I didn't have a well-defined architecture for my app.The blog post pointed out that another popular state management library, [Riverpod](https://riverpod.dev/), lets developers decide how to separate the app's logic into different layers. This was exactly my problem with flutter_bloc. It doesn't give you strong opinions on how to structure things.

The author of the blog post solved this by creating their own architecture that takes advantage of Riverpod's features. The key is to clearly define how the different layers of the app depend on each other before you even start writing code. This makes it easy to see which classes should be tested independently and which ones need to have their dependencies "faked" during testing.

When I first built Geml, I just focused on getting the app to work. I didn't start with a clear architecture. So, I'm not surprised that I haven't written many tests and that writing them now is difficult.

This Week's Plans

This week, I have two main things I'm aiming for. First, I'm going to try and finish half of a course that teaches the basics of Flutter app architecture. I'm hoping that seeing how another Flutter developer structures their apps will help me figure out the best way to structure my own apps in the future.

Second, I'm going to write some unit tests for the part of my app that doesn't rely on any other parts – the model layer. This will be a good starting point for testing the rest of my app

What Caught My Attention This Week

YouTube — 21 Mind Traps: The Ultimate Guide to Your Most Common Thinking Errors is a great introduction to common thinking errors that can affect our decision-making. The video explores 21 cognitive biases, including the spotlight effect, the anchoring effect, and confirmation bias. You'll learn how these biases can influence your thoughts and actions, and how to become more aware of them in your daily life. By understanding these biases, you can make more informed and rational decisions. Highly recommend.