How does Flutter calculate pixels for different resolutions?

会有一股神秘感。 提交于 2021-02-07 12:35:25

问题


Flutter apps can run on a variety of hardware, operating systems, and form factors. How are "pixels" calculated for different resolutions?


回答1:


From https://docs.flutter.io/flutter/dart-ui/Window/devicePixelRatio.html :

The number of device pixels for each logical pixel. This number might not be a power of two. Indeed, it might not even be an integer. For example, the Nexus 6 has a device pixel ratio of 3.5.

Device pixels are also referred to as physical pixels. Logical pixels are also referred to as device-independent or resolution-independent pixels.

By definition, there are roughly 38 logical pixels per centimeter, or about 96 logical pixels per inch, of the physical display. The value returned by devicePixelRatio is ultimately obtained either from the hardware itself, the device drivers, or a hard-coded value stored in the operating system or firmware, and may be inaccurate, sometimes by a significant margin.

The Flutter framework operates in logical pixels, so it is rarely necessary to directly deal with this property.



来源:https://stackoverflow.com/questions/44572330/how-does-flutter-calculate-pixels-for-different-resolutions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!