질문
보통 안드로이드에서는 dp를 사용하고, 아이폰에서는 pt(포인트)를 사용하여 측정합니다.
1 pt = 1/72 인치
1 dp = 1/160 인치
하지만 플러터에서는 측정 단위가 무엇인지 모르겠습니다.
예시:
SizedBox(height: 16.0)
또는
TextStyle(fontSize: 23.0)
이것은 단순히 숫자이며, 1.0에 해당하는 dp나 pt는 얼마인가요? 어떻게 계산되나요?
답변
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.
댓글