Slackbot
09/18/2025, 7:31 AMIndra
09/18/2025, 8:32 AMPlease remember this is a Slack team for Kotlin. If you have generic questions that are about a technology (which may or may not be used with Kotlin), maybe it's better to use another forum, such as StackOverflow.
---
You might want to start checking on the source for getChildAt in here, particulary on what happens if the child views holder is empty.Michael Krussel
09/18/2025, 10:51 AMView! type indicates that the library doesn't mean that the function will sometimes return null, it means that the Kotlin compiler doesn't know what the Java library will do, and you have to look at the documentation.
Now the documentation indicates that it does return null when out of range (this surprised me). So you can just do the safe cast and handle null as long as not existing and not being an AndroidComposeView has the same meaning for the code. But every time I would read it, I would be thinking this is broken if the view has no children until looking at the documentation again.