I want to call Text inside detectDragGestures it gives error
error: @Composable invocations can only happen from the context of a @Composable function
Canvas(
modifier = Modifier
.fillMaxSize()
.pointerInput(Unit) {
detectDragGestures(
onDragStart = { touch ->
Text("0")
},
)
}
)
If you want to show the
Textcomposable on drag then you manage amutableStatelike in this sample.Note: Don't forgot to set the variable to
falseafter drag ends.Also you can animate the
TextusingAnimatedVisibility.