Home > Mobile >  Cannot find a parameter with this name: indication
Cannot find a parameter with this name: indication

Time:08-19

Hello i'm trying to draw a Canvas in compose.. but when I use the indication parameter in Modifier.clickable() I get this error Cannot find a parameter with this name: indication

code:

@Composable
fun MiniFloatingActionButton(item: MultiFabItem, onFabItemClicked: (item: MultiFabItem) -> Unit) {
    Canvas(
        modifier = Modifier.size(32.dp)
            .clickable(
                onClick = { onFabItemClicked(item) },
                //Cannot find a parameter with this name: indication
                indication = rememberRipple(
                    bounded = false,
                    radius = 20.dp,
                    color = MaterialTheme.colors.onSecondary
                )
            )
    ) {
//        …
    }
}

CodePudding user response:

You have to add the interactionSource parameter

val interactionSource = remember { MutableInteractionSource() }

Canvas(
    modifier = Modifier.size(32.dp)
        .clickable(
            onClick = {  },
            indication = rememberRipple(
                bounded = false,
                radius = 20.dp,
                color = MaterialTheme.colors.onSecondary
            ),
            interactionSource = interactionSource
        )
) {
    //…
}

CodePudding user response:

You have to add interactionSource as well in the clickable.

If you don't have any interactionSource, use

interactionSource = remember { MutableInteractionSource() }
  • Related