๐ฑ 17 / 100 Days Of Flutter, Kate's edition โ aggressive decomposition, layout constraints demystified, and FittedBox
Hi, Flutter community and welcome to day 17 of my challenge ๐
I just started Andrea's course and immediately got sidetracked by tons of interesting things.
Aggressive decomposition
One of the recommendations that Andrea gives early on in the course is to use widget decomposition aggressively. In my past experiments and examples, I often had to deal with helper build methods. You will find them in pretty much every Flutter codelab.
It turned out that helper build methods are bad practice, primarily due to performance issues. Instead of wondering if I should extract a piece of Flutter tree into a separate widget, I should just go ahead and decompose it as much as possible.
It's very interesting to see a larger codebase organised using a feature-first file structure with aggressive decomposition in mind.
Layout constraints demystified
Constraints go down. Sizes go up. Parent sets position.
๐ฅ๐ฅ๐ฅ There is an amazing article by Marcelo Glasberg: docs.flutter.dev/development/ui/layout/cons.. ๐ฅ๐ฅ๐ฅ
I read it thoroughly and played with the demo app to understand layout constraints better.
Widget of the day - FittedBox
The constraints article showcases a few widgets that I haven't used yet. One of them is particularly interesting - FittedBox
.
It scales and positions its child within itself according to provided fit: contain, cover, fill, fitHeight, fitWidth, scaleDown, etc.
Summary
Today I learned very important Flutter concept - layout constraints. This article is an example of an exeptionally good technical documentation. Guess what's next on my plate? It's GoRouter!