我想获取屏幕的确切尺寸,而不考虑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时实际屏幕大小稍微大一些。
在下面的截图中,您可以看到我如何可以滚动一点点。
如何计算屏幕区域的确切高度?
谢谢您的阅读和帮助!