Expand description
How many device pixels one dp of a window covers, as the Renderer reports it.
The Host lays out in dp and never needs the number to place a box. It needs it for the
things that are about pixels: a page’s devicePixelRatio and its resolution media
queries, which image of a set to load, and snapping a hairline to the pixel grid. The
Renderer says what it is once before the first frame and again whenever it changes, as
when a window moves to a screen of another scale. Until it has, the value is 1.0.
It is separate from the zoom. A move between screens changes the density and leaves the zoom alone, and a zoom step does the reverse, so each has its own report.
Anything derived from the density (a cache of measurements, a chosen image) is stale
once it changes. subscribe is how its owner hears: the callback runs when a
different value arrives and never for a repeat of the same one.
Structs§
- Density
Subscription - A registration for changes to the density. Dropping it ends the registration.
- Window
Density Subscription - A registration for one window’s density. Dropping it ends the registration.
Constants§
- DEFAULT_
DENSITY - The density before the Renderer has reported one: one device pixel to the dp.
Functions§
- density
- What the Renderer last reported, or 1.0 before it has. Available outside a component too.
- density_
of - The density of one window, by the id of its
Windownode, or 1.0 for one that has not reported yet. - subscribe
- Registers
notifyto be called each time the Renderer reports a different density. - subscribe_
window - Registers
notifyto be called each time the windowwindowreports a different density.