MediaQuery (Flutter Widget of the Week)
Why Stack Overflow recommends it
Stack Overflow users link it when answering Flutter questions about responsive layouts, screen dimensions, and overflow errors, as a quick visual intro to MediaQuery.
Recommended by 2 people across 2 different months, 2019 to 2020.
What it is
A 1m39s entry in Flutter's official 'Widget of the Week' series, presented by the Flutter team, explaining the MediaQuery widget. It shows how to read screen size and user layout preferences to adapt an app's UI to different devices.
What people said
Recommends Achintha Isuru · 2019-09 · Stack Overflow · on “How to make flutter app responsive according to different screen size?”
This issue can be solved using MediaQuery.of(context) To get Screen width: MediaQuery.of(context).size.width To get Screen height: MediaQuery.of(context).size.height For more information about MediaQuery Widget watch, [this video]
Recommends UTKARSH Sharma · 2020-05 · Stack Overflow · on “RenderFlex overflowed Flutter”
Render overflow happens when the defined pixels(hardcoded heights, width or any dimensions). It will not happen until the widget collides with each other. To tackle this you would require dynamic height constraints basically speaking mediaQuery.MediaQuery will give you information about your device and one of the information is device size an example is provided below. I have provided an example below on how MediaQuery is implemented in basic applications. For in-depth details see this video [this video] class Dimensions { static double boxWidth; static double boxHeight; Dimensions(BuildContext context) { boxHeight = MediaQuery.of(context).size.height / 100; boxWidth = MediaQuery.of(context).size
Cites CopsOnRoad · 2019-05 · Stack Overflow · on “Flutter - Expand bottomNavigationBar by swiping or pressing the floatingActionButton”
@SaedNabil Here is what I was saying, take a look at this [this video] , you don't need `GlobalKey` for working with screen size. I already mentioned in 2nd comment `MediaQuery` is the simplest way to go.
Cites Yash Dixit · 2020-10 · Stack Overflow · on “flutter: how to suit all the screen sizes with the same program?”
When I usually create a flutter app, for its responsiveness I usually use these points: Use of Expanded [LINK] , Flexible [LINK] , and Spacer [LINK] Widgets when using Rows and Columns: All of these have a property called flex which is highly useful. Whenever I use rows or columns I use these widgets. Use of Layout Builder and Media Query widgets: These are there in the documentation: Creating responsive apps [LINK] (There are more articles on this flutter documentation which are recommended), can be used to know the screen size, the width, and the height, also how your apps function in different orientations. MediaQuery [this video] gives the width and height as follows: double w = MediaQuery.of