Impossible to use buttons in nodes
Issue #43
resolved
It’s impossible to use buttons or any widgets with onTap behaviour in nodeBuilder as Node catches all events.
Comments (5)
-
-
reporter I forked the package and tried this solution but it didn’t work.
I’m puzzled on how to have this to work…
-
Hi Franck, can you share some code. I have implemented this feature and I am currently testing it but I noticed that node with onTap set can still tap various widget that are able to receive the onTap (or onPressed) event. Below is a code snippet for my custom builder.
static Widget builder(BuildContext context, Node node) { return ListTile( dense: true, title: Row( children: [ SizedBox( width: 30, child: IconButton( onPressed: () { print(node.data); }, icon: Icon(Icons.info_outline), ), ), Text(node.label, style: TextStyle(fontSize: 16)), ], ), subtitle: InkWell( child: Text('testing'), onTap: () { print('testing'); }, ), contentPadding: EdgeInsets.all(0), horizontalTitleGap: 0, minVerticalPadding: 0, // subtitle: node.data == null ? null : Text(node.data), leading: makeIcon(node), trailing: SizedBox( width: 30, child: IconButton( onPressed: () { print(node.data); }, icon: Icon(Icons.info_outline), ), ), ); }
-
reporter Hi Kevin, I was using GestureDetector for the tap events. After adapting your example, everything works fine
Using SizedBox for the actions seems to be the clue.Thank you for your help!
-
reporter - changed status to resolved
- Log in to comment
Very true. I need to address this. One potential solution is to see if the an onTap method is provided on the TreeView. If not, do not wrap the label in an InkWell widget. Thoughts?