🌈 Create new beautiful Compose Gradients with our new wesite ->
Function

traverseChildren

Executes block for all direct children of the node with a matching key.

traverseChildrenWithKeyDemo

@Sampled
fun traverseChildrenWithKeyDemo() {
    val customTraversableModifierNode = CustomTraversableModifierNode()

    with(customTraversableModifierNode) {
        traverseChildren(traverseKey) {
            if (it is CustomTraversableModifierNode) {
                it.doSomethingWithChild()
            }
            // Return true to continue searching the tree after a match. If you were looking to
            // match only some of the nodes, you could return false and stop executing the search.
            true
        }
    }
}

/**
 * Simplified example of traverseChildren. For a full featured sample, look below at
 * [TraverseModifierDemo].
 */

traverseChildrenDemo

@Sampled
fun traverseChildrenDemo() {
    val customTraversableModifierNode = CustomTraversableModifierNode()

    with(customTraversableModifierNode) {
        traverseChildren {
            // Because I use the existing key of the class, I can guarantee 'it' will be of the same
            // type as the class, so I can call my functions directly.
            it.doSomethingWithChild()

            // Return true to continue searching the tree after a match. If you were looking to
            // match only some of the nodes, you could return false and stop executing the search.
            true
        }
    }
}

/**
 * Simplified example of traverseDescendants with a key. For a full featured sample, look below at
 * [TraverseModifierDemo].
 */