debugInspectorInfo

Function

Common
inline fun debugInspectorInfo(
    crossinline definitions: InspectorInfo.() -> Unit
): InspectorInfo.() -> Unit

Use this to specify modifier information for compose tooling.

This factory method allows the specified information to be stripped out by ProGuard in release builds.

Code Examples

InspectableModifierSample

@Composable
@Suppress("DEPRECATION")
fun InspectableModifierSample() {
    /** Sample with a single parameter */
    fun Modifier.simpleFrame(color: Color) =
        inspectable(
            inspectorInfo =
                debugInspectorInfo {
                    name = "simpleFrame"
                    value = color
                }
        ) {
            background(color, RoundedCornerShape(5.0.dp))
        }
    /** Sample with multiple parameters */
    fun Modifier.fancyFrame(size: Dp, color: Color) =
        inspectable(
            inspectorInfo =
                debugInspectorInfo {
                    name = "fancyFrame"
                    properties["size"] = size
                    properties["color"] = color
                }
        ) {
            background(color, RoundedCornerShape(size))
        }
}