Is there a way for a child composable to know its index in a parent?
I am aware that there is no built-in way to know this, but wondering if it is somehow possible to achieve this other than asking for the index as a fun param
Alex Styl
04/16/2025, 7:06 AM
This is for API design. Such as knowing if a tab is selected within a tab group
d
David
04/16/2025, 7:36 AM
I had a similar scenario not too long ago where we wanted to scroll to a certain item in a list of settings. From my research I could not find any good way to do this besides representing the entire settings view as a list and find the position of the element I wanted to scroll to that way. đ
a
agrosner
04/16/2025, 10:18 AM
Nope without passing a value down. One might ask âwhat is a parent?â If the composable is wrapped in multiple layers of parent composables
âđ» 1
z
Zach Klippenstein (he/him) [MOD]
04/16/2025, 3:43 PM
You could provide it as a composition local but if you have multiple potential âindexingâ parents it could be confusing