MediaQuery has many common flutter properties. Here are some common flutter properties. If there is more information, you can search for them elsewhere

For example, properties that we use all the time

// Get the screen size
MediaQuery.of(context).size
// By the way, the size of the current component after rendering
context.size
Copy the code

MediaQuery

MediaQuery can be used to handle a number of device or component issues, through which you can update a variety of content, such as screen rotation, inside margins, and so on

As such, other group properties are based on this component

const MediaQuery({
    Key key,
    @required this.data,
    @required Widget child,
})
Copy the code

MediaQuery.removePadding

Factory constructor for MediaQuery. This property allows you to set system-caused margins, such as margins for ios scroll views. When used, simply set removeTop to true and wrap our component with its child

MediaQuery.removePadding({
  Key? key,
  required BuildContext context,
  bool removeLeft = false,
  bool removeTop = false,
  bool removeRight = false,
  bool removeBottom = false,
  required Widget child,
});
Copy the code

Such as:

MediaQuery.removePadding(
    removeTop: true,
    context: context,
    child: ListView(
        children:[]
    ),
);
Copy the code

MediaQuery.of(context)

Simply pass in the current context to get some information about the system, as shown below, which can be reasonably used to adjust our layout. Here are some common attributes

Size: indicates the screen size

DevicePixelRatio: shielding percentage of pixels

PlatformBrightness: Light and Shade (normal mode, Dark mode)

Orientation: Screen orientation

ViewInsets is the screen margin occluded when the keyboard pops up, where viewInsets. Bottom is the keyboard height