Return nodeName instead of anchorName on Android (replicates upstream #13) - #1
Conversation
Return nodeName instead of anchorName on android like is done on iOS.
There was a problem hiding this comment.
Code Review
This pull request updates the node tap handler in ArView.kt to pass the tapped node's name directly instead of traversing the hierarchy to find the anchor name. The review feedback correctly identifies that this change leaves the parent-traversal loop and associated variables as dead code, which should be removed. Additionally, a null-safety check is recommended for the nullable nodeName before invoking the platform channel to avoid passing null values to Dart.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if (node != null) { | ||
| var anchorName: String? = null | ||
| var currentNode: Node? = node | ||
| val nodeName = node.name |
There was a problem hiding this comment.
Since nodeName is now used instead of anchorName for the tap event, the anchorName and currentNode variables, as well as the entire while loop traversing the parent hierarchy, are now dead code. They should be removed to clean up the codebase and avoid unnecessary parent-traversal and map-lookup operations on every tap.
| } | ||
| if(handleTaps) { | ||
| objectChannel.invokeMethod("onNodeTap", listOf(anchorName)) | ||
| objectChannel.invokeMethod("onNodeTap", listOf(nodeName)) |
There was a problem hiding this comment.
Since node.name is nullable, nodeName can be null. Passing a list containing null to the Flutter channel will result in tappedNode.toString() being called on null in Dart, which produces the string "null". To prevent this, we should only invoke the method if nodeName is not null.
| objectChannel.invokeMethod("onNodeTap", listOf(nodeName)) | |
| nodeName?.let { objectChannel.invokeMethod("onNodeTap", listOf(it)) } |
Review — VERDICT: ✅ LGTM (with nits)Replicates upstream hlefe#13. Kotlin-only; not compilable by
Safe to merge. |
Replicates upstream PR hlefe#13 by @Mako-L.
Change: In
ArView.kt,onNodeTapnow returns the tapped node's own name (node.name) instead of the resolved anchor name, matching the iOS behaviour.Original author: Mako-L. Upstream PR: hlefe#13