我有一个Row小部件。该行有一个Text作为子行(在本例中,它是一个SelectableText)。该行嵌入到InkWell小部件中,用于处理onTap()事件。这很好,除非我点击Text。在这种情况下,InkWell onTap()事件不会引发。
InkWell(
child: Row (
children: <Widget> [
SelectableText(...)
]
),
onTap: () => doSth();
)是否可以忽略Text的onTap()事件?我的解决方法是使用相同的代码将一个onTap()事件添加到Text中。但是,事实上,我想避免这种复制。
编辑:,实际上,Text小部件旁边还有一个Button小部件。不过,它的onPressed()事件应该可以像预期的那样工作。
InkWell(
child: Row (
children: <Widget> [
SelectableText(...),
Button(
onPressed: () {...}
)
]
),
onTap: () => doSth();
)发布于 2020-03-06 12:12:28
InkWell(
child: Row (
children: <Widget> [
IgnorePointer(
child: SelectableText(...)
)
]
),
onTap: () => doSth();
)发布于 2020-03-06 11:29:37
试试这个:
GestureDetector(
// behavior: HitTestBehavior.opaque,
onTap: () => doSth();
child: Row(
children: <Widget>[
SelectableText(...),
],
),
),https://stackoverflow.com/questions/60562597
复制相似问题