i have a project to do, sizes are set in dp units
if there is for example a container of height 20 dp, what height should it have in Flutter?
CodePudding user response:
Flutter sizes are in DP and not pixels. They are actually called LP(Logical Pixels).
Just set it to 20 and you are good to go.
CodePudding user response:
From https://api.flutter.dev/flutter/dart-ui/FlutterView/devicePixelRatio.html
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.