You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter开发求助:如何移除Body与BottomNavigationBar间的空白

解决Body与底部导航栏之间的空白问题

方案1:移除Body内容的底部内边距

你给Body里的所有内容设置了EdgeInsets.all(24.0)的内边距,这会让内容底部和导航栏之间多出24px的空白。直接修改padding,去掉底部的内边距即可:

body: SafeArea(
  bottom: false,
  child: Padding(
    // 只保留顶部、左右侧的内边距,移除底部
    padding: const EdgeInsets.only(top: 24.0, left: 24.0, right: 24.0),
    child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        // ... 其余代码不变
      ],
    ),
  ),
),

方案2:检查ResturantMenu组件的底部间距

如果改完padding还是有空白,去看ResturantMenu组件内部,比如如果它是ListView或者GridView,默认可能带底部padding。以ListView为例,把底部padding设为0:

// 在ResturantMenu组件的实现里
ListView(
  padding: EdgeInsets.only(bottom: 0),
  // ... 其余组件代码
)

方案3:调整导航栏的内边距

如果前两个方法都没用,试试给NavigationBar添加padding: EdgeInsets.zero,去掉它自带的默认内边距:

NavigationBar(
  height: 60,
  padding: EdgeInsets.zero, // 新增这一行
  onDestinationSelected: (int index) {
    setState(() {
      currentPageIndex = index;
    });
  },
  // ... 其余导航栏代码
),

内容的提问来源于stack exchange,提问作者Shaden

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.10 16:57:51