rememberDrawBoxController

fun rememberDrawBoxController(useCase: UseCase = UseCase(), initialState: State = State()): DrawBoxController

Composable factory function for creating and caching a DrawBoxController.

Uses Compose's viewModel API to ensure the same controller instance is retained across recompositions. Use this in your composable functions:

@Composable
fun MyScreen() {
val viewModel = rememberDrawBoxController()
val state by viewModel.state.collectAsState()
// ... use viewModel and state
}

Return

Remembered DrawBoxController instance

Parameters

useCase

Optional custom use case instance. If not provided, a default is created. Override for custom business logic or persistence.

initialState

State used when the controller is first created.