snapToPixelGrid static method
h on the physical-pixel grid of devicePixelRatio. Readings within
the same physical pixel collapse to one published value, so listeners
never see sub-pixel churn.
Implementation
@visibleForTesting
static double snapToPixelGrid(double h, double devicePixelRatio) =>
devicePixelRatio > 0
? (h * devicePixelRatio).roundToDouble() / devicePixelRatio
: h;