Flutter - InkWell not reacting to onTap inside Flexible
4,474
Wrapping IgnorePointer
inside the Inkwell's child will solve this:
Widget build(BuildContext context) {
return Card(
child: Container(
child: Row(
children: <Widget>[
Flexible(
child: InkWell(
onTap: () => print("Search"), //Is not printing anything
child: IgnorePointer(
child: TextField(
controller: controller,
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Searching..."
),
),
),
),
)
],
),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(8.0)
),
),
),
);
}
Author by
Admin
Updated on December 07, 2022Comments
-
Admin over 1 year
I am trying to figure out, why the
onTap()
method inside my InkWell is not working. The InkWell widget is inside aFlexible
widget. ThisFlexible
widget is also inside aRow
.Here is my code:
TextEditingController controller = new TextEditingController(); @override void dispose(){ super.dispose(); controller.dispose(); } @override Widget build(BuildContext context) { return Card( child: Container( child: Row( children: <Widget>[ Flexible( child: InkWell( onTap: () => print("Search"), //Is not printing anything child: TextField( controller: controller, decoration: InputDecoration( border: InputBorder.none, hintText: "Searching..." ), ), ), ) ], ), decoration: BoxDecoration( borderRadius: BorderRadius.all( Radius.circular(8.0) ), ), ), ); }
I do not know how to solve my problem. It would be awesome, if somebody would be able to solve it XD.
-
anmol.majhail over 5 yearsNo Issue, Thanks
-
Ali Akber about 3 yearsInkwell wasn't working for me inside a bottom sheet, but adding this worked. Could someone explain why this happens and why this solution works?
-
Ali Yar Khan almost 3 yearsIn mine case, it is not working working inside stack -> positioned -> row -> container ... adding the ignore pointer also doesn't benefit. What can be the issue ?
-
Chris over 2 yearsThanks! That was driving me craaaaazy ...