【发布时间】:2022-01-17 05:28:37
【问题描述】:
我试图在不考虑 AppBar 和 BottomNavigationBar 的情况下获得屏幕的确切尺寸
代码如下:
double screenSize = MediaQuery.of(context).size.height;
double height = screenSize - kToolbarHeight - kBottomNavigationBarHeight;
return SingleChildScrollView(
child: Column(
children: [
SizedBox(
height: height / 2,
child: Container(
color: Colors.red,
),
),
SizedBox(
height: height / 2,
child: Container(
color: Colors.blue,
),
),
],
),
);
通过这样做,我得到的高度比没有 AppBar 和 BottomNavigationBar 的实际屏幕尺寸略大
在下面的屏幕截图中,您可以看到我如何滚动一点
如何计算该屏幕区域的准确高度?
感谢您阅读并提供帮助!
【问题讨论】: