Closed
Description
Use case
In many places in Flutter apps, we only need one screen dimension (height or width). To get it we have to call MediaQuery.sizeOf(context).height
or MediaQuery.sizeOf(context).width
. This causes the widget to rebuild whenever any property of the size changes, even if we only care about one dimension. That's not ideal.
After checking the Flutter repo, I noticed that 14 out of 28 calls to sizeOf
use just one dimension. So this seems like a fairly common pattern.
Proposal
I'd like to propose adding four static functions to MediaQuery
:
MediaQuery.widthOf(context)
MediaQuery.maybeWidthOf(context)
MediaQuery.heightOf(context)
MediaQuery.maybeHeightOf(context)