gpt4 book ai didi

flutter - 可以获取Scaffold的body height和width吗?

转载 作者:IT王子 更新时间:2023-10-29 06:42:34 28 4
gpt4 key购买 nike

我正在尝试为我在我的应用程序中实现的小部件设置动态大小,我目前正在使用:

MediaQuery.of(context).size.width/height

这给了你屏幕的大小,但我需要小部件基于脚手架体的大小而不是全屏

最佳答案

您可以为脚手架使用构建器:

return Scaffold(
appBar: AppBar(),
body: Builder(
builder: (context) {
return Stack(
children: <Widget>[

然后:

bodyHeight = MediaQuery.of(context).size.height - Scaffold.of(context).appBarMaxHeight

至少,我以这种方式找到了解决方案。

关于flutter - 可以获取Scaffold的body height和width吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56612101/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com