CompositionLocalProvider¶
CompositionLocalProvider are used to provide a value for an CompositionLocal
How to provide a value for an CompositionLocal?¶
@Composable
private fun MyUserScreen() {
val user = User("Jens", 31)
CompositionLocalProvider(LocalActiveUser provides user) {
UserInfo()
}
}
<T>
provides T”. All child @Composable of CompositionLocalProvider will implicitly be able to get the value of the CompositionLocals. Last update: February 28, 2021