pixelsToFlutterUnits method

double pixelsToFlutterUnits(
  1. num pixels
)

double pixels is the value you want to convert from pixels to Flutter units. MediaQuery.of(context).devicePixelRatio retrieves the device's pixel ratio, which represents the number of physical pixels on the screen for each logical pixel in Flutter. pixels / pixelRatio performs the conversion by dividing the input pixels by the pixel ratio.

Implementation

double pixelsToFlutterUnits(num pixels) {
  return pixels.toDouble() / pixelRatio;
}