Description
This issue was originally filed by @seaneagan
Could replace:
MediaQueryList
Window.matchMedia
with:
class MediaQuery {
// parses/validates query
MediaQuery(this._query) native;
toString() => _query;
final String _query;
}
class Window {
// ...
Stream<bool> onMediaMatchChange(MediaQuery mq);
bool matchesMedia(MediaQuery mq);
}
If the Stream emitted an event corresponding to initial state at the time the Stream was created, then maybe the synchronous matchesMedia could be removed, and could just use Stream.first.then. Can checking a media query cause a layout ?
Example:
// parse/validate media query
var mq = new MediaQuery("(orientation: portrait)");
// initialize
setPortraitMode(window.matchesMedia(mq));
// handle updates
window.onMediaMatchChange(mq).listen(setPortraitMode);