如何让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
相关产品推荐
相关产品推荐

