[英]Flutter web how to get full screen size
I'm using MediaQuery.of(context).size.height
to get screen size (height in this case) of my flutter web as we do in mobile, but when I shrink chrome (aka web browser), MediaQuery
value is converts to shrunk screen size, what I want is fixed screen size which is equal to screen size of full screen.我正在使用
MediaQuery.of(context).size.height
来获取我的 flutter web 的屏幕尺寸(在这种情况下为高度),就像我们在移动设备中所做的那样,但是当我缩小 chrome 时(又名MediaQuery
浏览器)缩小屏幕尺寸,我想要的是固定屏幕尺寸,等于全屏的屏幕尺寸。 Can I do that?我可以这样做吗?
Thank-you谢谢
Just use SizedBox to force the screen size if it below minimum.如果它低于最小值,只需使用SizedBox强制屏幕尺寸。
final size = MediaQuery.of(context).size;
final minWidth = 800.0;
final minHeight = 600.0;
SizedBox(
width: size.width < minWidth ? minWidth : size.width,
height: size.height < minHeight ? minHeight : size.height,
child: const Card(child: Text('Hello World!')),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.