MediaQueryData class
Information about a piece of media (e.g., a window).
For example, the MediaQueryData.size property contains the width and height of the current window.
To obtain the current MediaQueryData for a given BuildContext, use the
MediaQuery.of function. For example, to obtain the size of the current
window, use MediaQuery.of(context).size
.
If no MediaQuery is in scope then the MediaQuery.of method will throw an
exception, unless the nullOk
argument is set to true, in which case it
returns null.
- Annotations
- @immutable
Constructors
- MediaQueryData({Size size: Size.zero, double devicePixelRatio: 1.0, double textScaleFactor: 1.0, EdgeInsets padding: EdgeInsets.zero, EdgeInsets viewInsets: EdgeInsets.zero, bool alwaysUse24HourFormat: false, bool invertColors: false, bool disableAnimations: false, bool boldText: false })
-
Creates data for a media query with explicit values. [...]
const
- MediaQueryData.fromWindow(Window window)
- Creates data for a media query based on the given window. [...]
Properties
-
Whether the user is using an accessibility service like TalkBack or
VoiceOver to interact with the application. [...]
final
- alwaysUse24HourFormat → bool
-
Whether to use 24-hour format when formatting time. [...]
final
- boldText → bool
-
Whether the platform is requesting that text be drawn with a bold font
weight. [...]
final
- devicePixelRatio → double
-
The number of device pixels for each logical pixel. This number might not
be a power of two. Indeed, it might not even be an integer. For example,
the Nexus 6 has a device pixel ratio of 3.5.
final
- disableAnimations → bool
-
Whether the platform is requesting that animations be disabled or reduced
as much as possible. [...]
final
- hashCode → int
-
The hash code for this object. [...]
read-only, override
- invertColors → bool
-
Whether the device is inverting the colors of the platform. [...]
final
- orientation → Orientation
-
The orientation of the media (e.g., whether the device is in landscape or portrait mode).
read-only
- padding → EdgeInsets
-
The number of physical pixels on each side of the display rectangle into
which the application can render, but which may be partially obscured by
system UI (such as the system notification area), or or physical
intrusions in the display (e.g. overscan regions on television screens or
phone sensor housings). [...]
final
- size → Size
-
The size of the media in logical pixel (e.g, the size of the screen). [...]
final
- textScaleFactor → double
-
The number of font pixels for each logical pixel. [...]
final
- viewInsets → EdgeInsets
-
The number of physical pixels on each side of the display rectangle into
which the application can render, but over which the operating system
will likely place system UI, such as the keyboard, that fully obscures
any content.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
copyWith(
{Size size, double devicePixelRatio, double textScaleFactor, EdgeInsets padding, EdgeInsets viewInsets, bool alwaysUse24HourFormat, bool disableAnimations, bool invertColors, bool boldText }) → MediaQueryData - Creates a copy of this media query data but with the given fields replaced with the new values.
-
removePadding(
{bool removeLeft: false, bool removeTop: false, bool removeRight: false, bool removeBottom: false }) → MediaQueryData - Creates a copy of this media query data but with the given paddings replaced with zero. [...]
-
removeViewInsets(
{bool removeLeft: false, bool removeTop: false, bool removeRight: false, bool removeBottom: false }) → MediaQueryData - Creates a copy of this media query data but with the given viewInsets replaced with zero. [...]
-
toString(
) → String -
Returns a string representation of this object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator. [...]
override