Navigating the Hard Parts of Testing in Flutter
Testing is critical for building quality software and particularly in Flutter apps, especially as they grow and become more complex. Even experienced developers often see tricky scenarios and corner cases in Flutter unit and widget tests. I’ve certainly hit several edge cases myself. When I asked on Linkedin many developers responded with similar experiences.
In this article, you'll find best practices, real-world examples, and ready-to-use sample code addressing common challenges, like handling date/time bugs, platform differences, testing customPainters, asynchronous operations, or tricky plugins.
Our focus is specifically on vanilla Flutter unit and widget tests, not state management libraries such as Riverpod, BLoC or integration tests. I think those deserve articles of their own, maybe for later! One of our goals is also to know how to boost your test coverage, while 100% test coverage is controversial and especially regarding quality of tests for covering everything; it's sometimes a good indication of what and where to test.
Let's get started!