CompositionLocalAccessorScope


Summary

Public properties

T

An extension property that allows accessing the current value of a composition local in the context of this scope.

Cmn

Public properties

currentValue

val CompositionLocal<T>.currentValue: T

An extension property that allows accessing the current value of a composition local in the context of this scope. This scope is the type of the this parameter when in a computed composition. Computed composition locals can be provided by either using compositionLocalWithComputedDefaultOf or by using the ProvidableCompositionLocal.providesComputed infix operator.

import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.compositionLocalOf

val LocalValue = compositionLocalOf { 10 }
val LocalLargerValue = compositionLocalOf { 12 }

@Composable
fun App() {
    CompositionLocalProvider(
        LocalLargerValue providesComputed { LocalValue.currentValue + 10 }
    ) {
        SomeScreen()
    }
}