如何在 AppBar 中包装子小部件以获得更大的子高度和 Flutter 中的填充

Posted

技术标签:

【中文标题】如何在 AppBar 中包装子小部件以获得更大的子高度和 Flutter 中的填充【英文标题】:How to wrap child widgets in AppBar for larger child heights and paddings in Flutter 【发布时间】:2021-09-23 13:24:54 【问题描述】:

我一直在努力寻找一种基于动作图标大小及其填充来适应 AppBar 高度的方法。当为前导和操作图标提供填充时,它们会被 AppBar 覆盖。有没有什么方法可以实现这个功能?This is how it should work

【问题讨论】:

【参考方案1】:

您可以尝试根据设备高度设置应用栏高度

 appBar: PreferredSize(
          preferredSize: Size.fromHeight(MediaQuery.of(context).size.height * 0.2), // here the desired height
          child: AppBar(
            // ...
          )
        ),

【讨论】:

以上是关于如何在 AppBar 中包装子小部件以获得更大的子高度和 Flutter 中的填充的主要内容,如果未能解决你的问题,请参考以下文章