Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ class ArView(
if (node != null) {
var anchorName: String? = null
var currentNode: Node? = node
val nodeName = node.name

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

while (currentNode != null) {
anchorNodesMap.forEach { (name, anchorNode) ->
if (currentNode == anchorNode) {
Expand All @@ -511,7 +512,7 @@ class ArView(
currentNode = currentNode.parent
}
if(handleTaps) {
objectChannel.invokeMethod("onNodeTap", listOf(anchorName))
objectChannel.invokeMethod("onNodeTap", listOf(nodeName))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
objectChannel.invokeMethod("onNodeTap", listOf(nodeName))
nodeName?.let { objectChannel.invokeMethod("onNodeTap", listOf(it)) }

}
true
} else {
Expand Down Expand Up @@ -1328,4 +1329,4 @@ class ArView(
}


}
}