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

如何在Flutter中使用CustomPainter制作带FAB凹槽的底部导航栏

实现带FAB凹槽的CustomPainter底部导航栏

问题

需要制作一款基于CustomPainter的底部导航栏,核心是实现FloatingActionButton对应的凹槽/边缘造型。

已完成的解决方案更新

我通过自定义FloatingActionButtonLocation类,完成了FAB的定位,从而实现了预期的凹槽效果,代码如下:

class CustomFABLocation extends FloatingActionButtonLocation {
  const CustomFABLocation({
    required this.bottomBarHeight,
  });

  final double bottomBarHeight;

  @override
  Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) {
    final xPos = scaffoldGeometry.scaffoldSize.width * .4;
    final yPos = scaffoldGeometry.scaffoldSize.height - bottomBarHeight - 13.0;

    return Offset(xPos, yPos);
  }
}

效果展示

带FAB凹槽的底部导航栏效果

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 18:15:40