The physical resolution of the phone

final physicalWidth = window.physicalSize.width; final physicalHeight = window.physicalSize.height; Print (' physicalWidth: $physicalHeight');Copy the code

The size of the phone’s screen (logical resolution)

final width = MediaQuery.of(context).size.width;
final height = MediaQuery.of(context).size.height;
Copy the code

To obtain the DPR

final dpr = window.devicePixelRatio; Final Width = physicalWidth/DPR; final height = physicalHeight / dpr; Print ($width * $height);Copy the code

Height of the status bar

final statusHeight = window.padding.top / dpr; Print (' status bar height: $statusHeight');Copy the code

Size adaptation

class SizeFit { static double physicalWidth; static double physicalHeight; static double dpr; static double screenWidth; static double screenHeight; static double statusHeight; static double rpx; Static void init () {/ / 1. Mobile phone physicalWidth = window. The physical resolution physicalSize. The width; physicalHeight = window.physicalSize.height; DPR = window.devicepixelRatio; ScreenWidth = physicalWidth/DPR; screenWidth = physicalWidth/DPR; screenHeight = physicalHeight /dpr; //4. StatusHeight = window.padding.top; RPX = screenWidth / 750; } fitWidth(width) { return rpx * width; }}Copy the code