Home > Mobile >  What is the use of logical pixel in flutter?
What is the use of logical pixel in flutter?

Time:07-08

I am not interested in inside workings of logical pixels, I just want to know if flutter automatically use logical pixel

Container(
  width:100,
  child:...
)

Does flutter uses 100 pixel or logical pixel as width here, I can't figure it out.

CodePudding user response:

You can print screen width

double kScreenWidth(BuildContext ctx) => MediaQuery.of(ctx).size.width;

you can see what it is like

Container(width: 100, ...)

logical pixels

So obvious,

What you see is what you got.


Flutter follows a simple density-based format like iOS. Assets might be 1.0x, 2.0x, 3.0x, or any other multiplier.

Flutter doesn’t have dps but there are logical pixels, which are basically the same as device-independent pixels. The so-called devicePixelRatio expresses the ratio of physical pixels in a single logical pixel.

from flutter dev doc

  • Related