直接看代码案例快速入手Flutter
本文介绍MediaQuery.
MediaQuery主要用于获取当前设备的一些参数。
🎉下载GitHub仓库,直接体验
MediaQuery
double screenWidth = MediaQuery.of(context).size.width;
double screenHeight = MediaQuery.of(context).size.height;
Orientation orientation = MediaQuery.of(context).orientation;
double devicePixelRatio = MediaQuery.of(context).devicePixelRatio;
double statusBarHeight = MediaQuery.of(context).padding.top;
double bottomBarHeight = MediaQuery.of(context).padding.bottom;
double textScaleFactor = MediaQuery.of(context).textScaleFactor;
Brightness brightness = MediaQuery.of(context).platformBrightness;