Flutter MediaQuery

直接看代码案例快速入手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;
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容