Flutter 颤振芯片可点击化身不工作

Flutter 颤振芯片可点击化身不工作,flutter,Flutter,我正在GridView builder中创建一个原始芯片的动态列表,我希望当用户单击avatar图标时,从列表中删除该项目,但从未调用单击功能 我尝试用InkWell或GestureDetector包装头像图标并使用onTap函数我调试了代码并尝试了onTap中的一些断点,但它从未被调用,也没有单击声音,甚至从GridView外部调用了chipBuilder函数,但它仍然没有被调用onTap() GridView小部件 GridView.builder( 物理学:NeverscrollableS

我正在GridView builder中创建一个原始芯片的动态列表,我希望当用户单击avatar图标时,从列表中删除该项目,但从未调用单击功能

我尝试用InkWell或GestureDetector包装头像图标并使用onTap函数我调试了代码并尝试了onTap中的一些断点,但它从未被调用,也没有单击声音,甚至从GridView外部调用了chipBuilder函数,但它仍然没有被调用onTap()

GridView小部件

GridView.builder(
物理学:NeverscrollableScroll物理学(),
收缩膜:对,
滚动方向:轴垂直,
itemCount:storingDataList.length,
gridDelegate:SliverGridDelegateWithFixedCrossAxisCount(
交叉轴计数:3,
儿童方面:3,
横轴间距:10,
主轴间距:8),
itemBuilder:(上下文,索引)=>chipBuilder(
标签:storingDataList[索引],
Onavatap:(){
创建(“项目移除”,上下文);
设置状态(){
storingDataList.removeAt(索引);
});       
}));
芯片生成器功能:

Widget-chipBuilder({String-label,VoidCallback-onAvatarTap})=>RawChip(
阿凡达:墨水井(
onTap:onAvatarTap,
子:容器(
装饰:盒子装饰(
颜色:colors.colorTextPrimary,
边界半径:边界半径。圆形(12)),
子:图标(
图标。关闭,
颜色:colors.colorPrimary,
),
),
),
背景颜色:colors.colorPrimary,
MaterialTargetSize:MaterialTargetSize.shrinkWrap,
标签:文本(标签,
样式:CustomTextStyles.textSecondary.copyWith(颜色:Colors.white)),
labelStyle:CustomTextStyles.textSecondary.copyWith(颜色:Colors.white),
形状:圆形矩形边框(
边界半径:边界半径。圆形(12.0),
边:边框边(颜色:colors.colorPrimary,宽度:0)),
);
我没有收到任何错误消息

电流输出: 感谢您为我指出了这方面的问题

此行为的原因是因为RawChip正在使用tap事件。为什么不使用 onPressed:来自RawChip

如果SelectableChipAttributes.onSelected、TappableChipAttributes.onPressed和DeletableChipAttributes.onDelete均为空,则RawChip的行为就像它被禁用一样

我已经从
avatar:
中删除了InkWell,我将我的图标放在
deleteIcon:
中,而不是
avatar:
,我使用
onDeleted:
函数调用onAvatarTap,它成功了

Widget-chipBuilder({String-label,VoidCallback-onAvatarTap})=>RawChip(
未删除:Onavatap,
删除图标:容器(
装饰:盒子装饰(
颜色:colors.colorTextPrimary,
边界半径:边界半径。圆形(12)),
子:图标(
图标。关闭,
颜色:colors.colorPrimary,
),
),
背景颜色:colors.colorPrimary,
MaterialTargetSize:MaterialTargetSize.shrinkWrap,
标签:文本(标签,
风格:
CustomTextStyles.textSecondary.copyWith(颜色:Colors.white)),
标签样式:
CustomTextStyles.textSecondary.copyWith(颜色:Colors.white),
形状:圆形矩形边框(
边界半径:边界半径。圆形(12.0),
边:边框边(颜色:colors.colorPrimary,宽度:0)),
);
感谢您为我指出了这方面的问题

此行为的原因是因为RawChip正在使用tap事件。为什么不使用 onPressed:来自RawChip

如果SelectableChipAttributes.onSelected、TappableChipAttributes.onPressed和DeletableChipAttributes.onDelete均为空,则RawChip的行为就像它被禁用一样

我已经从
avatar:
中删除了InkWell,我将我的图标放在
deleteIcon:
中,而不是
avatar:
,我使用
onDeleted:
函数调用onAvatarTap,它成功了

Widget-chipBuilder({String-label,VoidCallback-onAvatarTap})=>RawChip(
未删除:Onavatap,
删除图标:容器(
装饰:盒子装饰(
颜色:colors.colorTextPrimary,
边界半径:边界半径。圆形(12)),
子:图标(
图标。关闭,
颜色:colors.colorPrimary,
),
),
背景颜色:colors.colorPrimary,
MaterialTargetSize:MaterialTargetSize.shrinkWrap,
标签:文本(标签,
风格:
CustomTextStyles.textSecondary.copyWith(颜色:Colors.white)),
标签样式:
CustomTextStyles.textSecondary.copyWith(颜色:Colors.white),
形状:圆形矩形边框(
边界半径:边界半径。圆形(12.0),
边:边框边(颜色:colors.colorPrimary,宽度:0)),
);