It's a simple concept, but have you ever wanted your parent widget to just adjust its size to its child/children?
If so, it's incredibly easy to do it!
However, you have to pick between height and width.
All you have to do is wrap the said parent with the IntrinsicHeight or IntrinsicWidth class and you're all set!
But be careful not to abuse it! This is an "expensive" widget to use and it will affect your app's performance if you use it too much.
It has quite a specific use case so that probably won't be a problem. At least I don't imagine that you'll have a lot of occasions in which you need a certain amount of children to all be as big in size as the biggest child (height or width wise).
So, if you want to learn how to make a widget's children all fit the biggest of them, this would be how. Whether it's biggest in height or in width, either one of these will work. Instead of fit to parent or fit to child, they kind of just fit each other. And of course, we must thank the Flutter team for creating this responsive layout widget/class to make our lives easier!
Just watch the video to see an example of this taking place.
IntrinsicHeight class documentation: https://api.flutter.dev/flutter/widge...
IntrinsicWidth class documentation: https://api.flutter.dev/flutter/widge...
GitHub Project Repository: https://github.com/FlutterMentor/intr...
00:00 - Intro
00:33 - Code Overview
01:44 - The cheap fix (don't do this)
02:25 - Using the IntrinsicHeight class
03:35 - Using the IntrinsicWidth class
04:18 - WARNING!
05:00 - Final Conclusions
05:30 - Like & Subscribe
05:36 - Flutter Mentor Out
#flutter #intrinsicheight #intrinsicwidth
Credits:
OUTRO SONG:
Mitsubachi by Smith The Mister https://smiththemister.bandcamp.com
Smith The Mister https://bit.ly/Smith-The-Mister-YT
Free Download / Stream: http://bit.ly/mitsubachi
Music promoted by Audio Library • Mitsubachi – Smith The Mister (No Cop...