我试图在不考虑 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,
),
),
],
),
);
Run Code Online (Sandbox Code Playgroud)
通过这样做,我得到的高度比实际屏幕尺寸稍大,没有 AppBar 和 BottomNavigationBar
在下面的屏幕截图中,您可以看到我如何滚动一点
如何计算该屏幕区域的准确高度?
感谢您阅读我的文章并提供帮助!