Reputation: 6835
I create a composable with a Modifier as a parameter. Although I do not think that this would be possible, but is there anyway a method by which I can retrieve the values passed in to this modifier?
{
mComp(Modifier.height(100.dp).width(100.dp))
}
@Composable
fun mComp(modifier: Modifier){ // Yeah I know Composable names should start with a Cap Letter
//Retrieve the height and width here. How?
}
Upvotes: 2
Views: 1796
Reputation: 29260
This is not possible and it is intentional. For instance, in a coroutine flow
you can't query in the collector whether a filter
was applied or not, it's opaque, and the same applies to modifiers. If you want to retrieve some argument from a modifier you can create your custom one, this article shows how to do so
Upvotes: 2