-
Notifications
You must be signed in to change notification settings - Fork 29.5k
Closed
Labels
c: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework team
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)AbdeMohlbi, navaronbracke and itspectre
Metadata
Metadata
Assignees
Labels
c: new featureNothing broken; request for a new capabilityNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamOwned by Framework team