What is Canvas api in Android ?
In Jetpack Compose, the Canvas API is a declarative, stateless way to draw custom shapes, paths, and images. Unlike the traditional View system where you override onDraw(canvas) , Compose uses a Canvas composable that provides a DrawScope . Canvas(modifier = Modifier.size( 200. dp)) { // The DrawScope starts here drawCircle( color = Color.Blue, radius = size.minDimension / 4 , center = center // 'center' and 'size' are provided by DrawScope ) } Lifecycle The Canvas follows the standard Compose "Three Phases" of a frame, but it spends most of its time in the final phase. Composition (What to show) Compose determines that a Canvas should be part of the UI tree. If you use mutableStateOf inside your onDraw block, Compose tracks this as a dependency. Layout (Where to show it) The Modifier.size() or constraints from the parent determine the Canvas's hei...