Function

modifierLocalOf

Creates a ProvidableModifierLocal and specifies a default factory.

modifierLocalOf

Source set: Common
public fun <T> modifierLocalOf(defaultFactory: () -> T): ProvidableModifierLocal<T>

Creates a ProvidableModifierLocal and specifies a default factory.

Here are examples where a modifier can communicate with another in the same modifier chain:

Sample 1: Modifier sending a message to another to its right.

Sample 2: Modifier sending a message to another to its left.

Here are examples where a modifier can communicate with another across layout nodes:

Sample 1: Modifier sending a message to a modifier on a child layout node.

Sample 2: Modifier sending a message to a modifier on a parent layout node.

Parameters

defaultFactory a factory to create a default value in cases where a ModifierLocal is consumed without a Provider. If this is a situation you would rather not handle, you can throw an error in this factory.
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: