How do you create a Flutter card layout that grows horizontally up to a given width, then remains fixed at that width just like in this example?
This can be done by composing Center
and SizedBox
widgets like so:
Why does this work?
Well, it's all about tight vs loose constraints:
- Center has loose constraints
- SizedBox has tight constraints
Combine them together for profit.
This excellent article by @mhadaily explains all the details:
Found this useful? Show some love and share the original tweet 🙏
Previous | Next |
---|---|
How to Validate a TextField in Flutter |
How to navigate programmatically between tabs in Flutter |