> ```* [graphicsLayer] can be used to apply eff...
# compose
n
```* [graphicsLayer] can be used to apply effects to content, such as scaling, rotation, opacity,
* shadow, and clipping.
* Prefer this version when you have layer properties backed by a
* [androidx.compose.runtime.State] or an animated value as reading a state inside [block] will
* only cause the layer properties update without triggering recomposition and relayout.```
This is the documentation of graphics layer. From this it looks like i can make changes to the graphics layer without recomposing the parent composable. But how to I collect a state in the graphics layer as it is not a composable? If i collect a state in the parents then it will recompose the parent.
f
But how to I collect a state in the graphics layer as it is not a composable?
You don't need to be in Composable context to read snapshot state
n
@Filip Wiesner I need to
.collectAsState()
somewhere. The
Composable
in which i collect at state will recompose when the state changes right? Even if i use it or not?
f
You are talking about
kotlinx.coroutines.flow.Flow
API but the documentation talks about
androidx.compose.runtime.State
.The
collectAsState()
is transformation between these two APIs. And I think it should not matter where you make this transformation. What matters is where you read the resulting state.
So basically I think that this
The
Composable
in which i collect at state will recompose when the state changes.
is not true.
n
Ok, If i collect the state it will not recompose. Only when i read the value from the state. the composable will recompose.
Thanks @Filip Wiesner
👌 2