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

如何让Showcase组件显示在文本上方?已实现但显示于文本下方

调整Showcase组件的显示位置

要把Showcase的标题和描述放到目标文本上方,只需要给Showcase组件添加placement参数并设置为Placement.top即可,这个参数用于控制Showcase内容相对于目标组件的位置。

修改后的完整代码:

Showcase(
  key: keys,
  overlayOpacity: 0,
  overlayColor: Colors.transparent,
  title: "New!",
  titleTextStyle: TextStyle(fontSize: 12),
  shapeBorder: const CircleBorder(),
  showcaseBackgroundColor: Color(0xfffcecaf),
  descTextStyle:
      const TextStyle(fontWeight: FontWeight.bold, fontSize: 13),
  description: "Tap to Learn more",
  // 指定Showcase内容显示在目标组件上方
  placement: Placement.top,
  child: Container(
    child: Text(
      "xyz",
      style: TextStyle(
        fontSize: 20,
        height: 1.2,
        color: AppColors.PRIMARY_COLOR,
      ),
    ),
  ),
),

如果设置后位置仍不符合预期,可以额外调整targetPadding参数微调间距,比如targetPadding: EdgeInsets.symmetric(vertical: 10),根据实际需求调整数值即可。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.23 10:18:38