Ignore onTap() event for Text -> Take onTap() event of parent Row instead
331
Use an IgnorePointer
InkWell(
child: Row (
children: <Widget> [
IgnorePointer(
child: SelectableText(...)
)
]
),
onTap: () => doSth();
)
Author by
S-Man
Author Advanced PostgreSQL Querying ISBN 978-3752967340
Updated on December 18, 2022Comments
-
S-Man over 1 year
I have a
Row
widget. This row has aText
as child (in this case, it is aSelectableText
). The row is embedded into anInkWell
widget for handlingonTap()
events. This works fine unless I tap theText
. In that case theInkWell
onTap()
event is not raising.InkWell( child: Row ( children: <Widget> [ SelectableText(...) ] ), onTap: () => doSth(); )
Is it possible to ignore the
Text
foronTap()
events? My workaround would be to add anonTap()
event to theText
as well with the same code. But, in fact, I want to avoid this replication.
Edit: In fact, there's also a
Button
widget next to theText
widget. ItsonPressed()
event should work as expected, nevertheless.InkWell( child: Row ( children: <Widget> [ SelectableText(...), Button( onPressed: () {...} ) ] ), onTap: () => doSth(); )
-
Darish about 4 years@S-Man are you trying to just disable the TextField by catching tap events by InkWell onTap method?
-
S-Man about 4 years@Darish Argh... Not TextField, of course. It's a Text(A SelectableTextin this special case)... Sorry for confusion, changed the question
-
NoobN3rd about 4 yearsAre You looking for
AbsorbPointer
?
-
-
S-Man about 4 yearsThis would ignore the onPressed() events of the Button widget, which is a sibling of the Text widget (see Edit in the question)
-
Omar Fayad about 4 yearsjust remove behavior: HitTestBehavior.opaque, it should work
-
S-Man about 4 yearsThis made it! Thanks!