I can think of 6 very common sources of errors in Flutter apps.
With a bit of planning and attention, each one can be solved.
Let's take a look. 🧵
Solution: variables should be non-nullable by default unless there's a good reason not to.
And make sure you also use all the null-aware operators (?
, !
, ?.
, !.
, ??
) correctly.
Packages like Freezed and the Data Class extension help with this. Use them.
Many state management packages prefer immutable data for good reason (don't fight them)
Solution: plan (and design for) error handling in relation to your application layers (e.g. widgets, state, repositories, services)
Also install (and properly use) an error reporting tools to catch errors in the wild.
This can cause widgets to show old data or not update when they should.
So think about each individual source of realtime data (streams, state notifiers) and design your widgets accordingly.
This will cause bugs and regressions and will bite you hard as your codebase grows.
Solution: strategically write tests for new features. When you find a bug, write a failing test and fix it.
If that's your thing, do TDD.
The good news is that with a repeatable and well defined development process, all these issues can be solved, consistently.
Found this useful? Show some love and share the original tweet 🙏
Previous | Next |
---|---|
Easily handle loading and error states | How to create a Flutter GridView with content-sized items |