I have this widget:
InkWell(
onTap: () {
print('Tapped');
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Text('Text'),
TextButton( // <- I tried to wrap it with AbsorbPointer.
child: Text('Disable'),
onPressed: null,
),
],
),
),
It is an InkWell
with an onTap
(in this example, it only prints 'Tapped'
), and inside there is a button that can be (not all the time) disabled.
My issue is that when the TextButton
is disabled, clicking on it triggers the onTap
of the InkWell
. I would like to block this and if the user clicks on the disable button, nothing happens.
I tried to wrap the TextButton
with an AbsorbPointer
but it didn’t work.
How can I do that?
2
Answers
You can sync the state of
InkWell
andTextButton
.It will be better if you move your actions out of widget codes
if you want to keep the ripple effect from the inkwell without executing something when the inkwell is tapped, dont set the onTap parameter to null, set to
ontap: (){}
insteadhere’s the example