To occupy the whole width or height , I use double.infinity
, but going through some of the flutter samples, I have noticed many people use MediaQuery.of(c
The difference can be summarized into:
Usually, you'll want to use double.infinity
, but it's not always possible.
Some Widgets allow their children to be as big as they want to be (Column
, ListView
, OverflowBox
...). In that situation using double.infinity
creates a paradox:
Using MediaQuery
in these situations is bad though. You will rarely want to do that unless you're creating a widget similar to Scaffold
.
That's where widgets such as IntrinsincHeight
comes in handy. These widgets are able to solve the paradox, and therefore have a valid layout.