Declare a just-in-time composition of a [Modifier] that will be composed for each element it modifies.
InspectorInfoInComposedModifierSample
@Suppress("UnnecessaryComposedModifier")
@Composable
fun InspectorInfoInComposedModifierSample() {
// let's create your own custom stateful modifier
fun Modifier.myColorModifier(color: Color) =
composed(
// pass inspector information for debug
inspectorInfo =
debugInspectorInfo {
// name should match the name of the modifier
name = "myColorModifier"
// specify a single argument as the value when the argument name is irrelevant
value = color
},
// pass your modifier implementation that resolved per modified element
factory = {
// add your modifier implementation here
Modifier
},
)
}
InspectorInfoInComposedModifierWithArgumentsSample
@Suppress("UnnecessaryComposedModifier")
@Composable
fun InspectorInfoInComposedModifierWithArgumentsSample() {
// let's create your own custom stateful modifier with multiple arguments
fun Modifier.myModifier(width: Dp, height: Dp, color: Color) =
composed(
// pass inspector information for debug
inspectorInfo =
debugInspectorInfo {
// name should match the name of the modifier
name = "myModifier"
// add name and value of each argument
properties["width"] = width
properties["height"] = height
properties["color"] = color
},
// pass your modifier implementation that resolved per modified element
factory = {
// add your modifier implementation here
Modifier
},
)
}