MediaQueryList extension type
A MediaQueryList
object stores information on a
media query
applied to a document, with support for both immediate and event-driven
matching against the state of the document.
You can create a MediaQueryList
by calling Window.matchMedia on the
window object. The resulting object handles sending notifications to
listeners when the media query state changes (i.e. when the media query test
starts or stops evaluating to true
).
This is very useful for adaptive design, since this makes it possible to observe a document to detect when its media queries change, instead of polling the values periodically, and allows you to programmatically make changes to a document based on media query status.
- on
- Implemented types
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- matches → bool
-
no setter
- media → String
-
no setter
- onchange ↔ EventHandler?
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addEventListener(
String type, EventListener? callback, [JSAny options]) → void -
The
addEventListener()
method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.inherited -
addListener(
EventListener? callback) → void -
The deprecated
addListener()
method of the MediaQueryList interface adds a listener to theMediaQueryListener
that will run a custom callback function in response to the media query status changing. -
dispatchEvent(
Event event) → bool -
The
dispatchEvent()
method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually withdispatchEvent()
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeEventListener(
String type, EventListener? callback, [JSAny options]) → void -
The
removeEventListener()
method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.inherited -
removeListener(
EventListener? callback) → void -
The
removeListener()
method of the MediaQueryList interface removes a listener from theMediaQueryListener
. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited