I have code I want to add draggable box but it is not able to create draggable box, Something is missing in code
a code I want to make draggable box but in screen it show nothing
val state = rememberDraggableState()
Box(modifier = Modifier.draggable(
state = state,
orientation = Orientation.Vertical,
onDragStarted = { Log.d("Box", "Starting Drag") },
onDragStopped = { Log.d("Box", "Finishing Drag") }
))
When you want to drag or move any element you need to set its Offset value so first you are missing it and then how to update and when to update it.
Let's break down the example
offsetYand set Initial value to0fonDeltamethod ofrememberDraggableStateand when drag stopped it will return a delta which we will used to add in current offsetY value and update itcomposableoffset using theoffsetYvalueCode
Preview