🌈 Create new beautiful Compose Gradients with our new wesite ->
Function

modifierLocalOf

Creates a ProvidableModifierLocal and specifies a default factory.

ModifierLocalParentChildCommunicationWithinLayoutNodeSample

@Sampled
@Composable
fun ModifierLocalParentChildCommunicationWithinLayoutNodeSample() {

    // Define the type of data.
    val ModifierLocalMessage = modifierLocalOf { "Unknown" }

    Box(
        Modifier
            // Provide an instance associated with the data type.
            .modifierLocalProvider(ModifierLocalMessage) { "World" }
            .composed {
                var message by remember { mutableStateOf("") }
                Modifier
                    // Use the data type to read the message.
                    .modifierLocalConsumer { message = ModifierLocalMessage.current }
                    .clickable { println("Hello $message") }
            }
    )
}

ModifierLocalChildParentCommunicationWithinLayoutNodeSample

@Sampled
@Composable
fun ModifierLocalChildParentCommunicationWithinLayoutNodeSample() {

    class Sender(val onMessageReceived: (String) -> Unit) {

ModifierLocalParentChildCommunicationInterLayoutNodeSample

@Sampled
@Composable
fun ModifierLocalParentChildCommunicationInterLayoutNodeSample() {

    // Define the type of data.
    val ModifierLocalMessage = modifierLocalOf { "Unknown" }

    Box(
        // Provide an instance associated with the data type.
        Modifier.modifierLocalProvider(ModifierLocalMessage) { "World" }
    ) {
        var message by remember { mutableStateOf("") }
        Box(
            Modifier
                // Use the data type to read the message.
                .modifierLocalConsumer { message = ModifierLocalMessage.current }
                .clickable { println("Hello $message") }
        )
    }
}

ModifierLocalChildParentCommunicationInterLayoutNodeSample

@Sampled
@Composable
fun ModifierLocalChildParentCommunicationInterLayoutNodeSample() {

    class Sender(val onMessageReceived: (String) -> Unit) {