MediaQuery has always existed in WidgetsApp and MaterialApp. MediaQuery is an independent widget inherited from InheritedWidget, but it usually gets relevant information through MediaQuery.of(context).
When the relevant information changes, such as screen rotation, the Widget in the screen will be rebuilt to keep the latest state; We can manually set relevant information through the MediaQuery constructor and the provided static method;
MediaQueryData contains information about the media; Generally obtained through MediaQuery.of(context);
Size is the size of the medium, in logical pixels;
DevicePixelRatio is pixels per inch; It is related to the physical pixels of the device and has nothing to do with the horizontal and vertical screens;
Direction is horizontal screen and vertical screen, direction. Horizontal screen, direction. Vertical screen;
TextScaleFactor is
The pixel number of each logical pixel in the font is understood as the pixel ratio of the font; Note that after setting the default font pixel per inch to the standard 1.2 times, the font size of the equipment system has been adjusted, and its 1.2 times is still enlarged by 1.2 times on the basis of the standard font size;
PlatformBrightness is the brightness mode of the current device; Note that adjusting the screen brightness will not change this mode, which is related to the dark mode and light mode supported by the current system;
AlwaysUse24HourFormat is whether the current device is a 24-hour system;
AccessibleNavigation refers to whether to use assistive functions such as TalkBack or VoiceOver to interact with applications to assist visually impaired people;
InvertColors is whether to use color inversion, which is mainly used for iOS devices;
HighContrast is whether users require high contrast between foreground and background, which is mainly used for iOS devices.
DisableAnimations is whether the platform requires that animation be disabled or reduced;
BoldText indicates whether the platform needs bold;
Filling is the inner margin of the screen, which is generally the margin of the part of Liu Haier screen or special-shaped screen blocked by the system;
Viewinserts is the screen margin when the keyboard pops up, where viewInsets.bottom is the height of the keyboard;
SystemGestureInsets are gesture margins, such as sliding left to close the page after Android Q;
ViewPadding is understood as the inner margin of the view, which is the part of the screen blocked by Liu Haier screen or special-shaped screen, and is calculated from the edge of the MediaQuery boundary; This value remains unchanged; For example, the soft keyboard at the bottom of the screen may cover and occupy the area that also needs to be filled at the bottom, so it will not affect this value;
PhysicalDepth is the physical level of equipment, and the corresponding application scenario has not been thought of for the time being;
There are two things to note when trying to get other subassembly sizes. First, a GlobalKey should be set to get the current position, and the key should be unique. Secondly, the context of BuildContext is obtained through GlobalKey (). CurrentContext, so as to obtain the corresponding size;
MediaQuery case attempt
The application and understanding of some MediaQueryData side dishes are not deep enough; If there are any mistakes, please advise!