Home > Net >  How to get exact size without recomposition?
How to get exact size without recomposition?

Time:08-15

I need size of my composable to draw dynamic lines but I don't want to get size by:

var size by remember { mutableStateOf(IntSize.Zero) }

Modifier.onSizeChanged{size = it}

or

Modifier.onGloballyPositioned{size = it.size}

because I don't want to recompose.

Currently I am getting size from BoxWithConstraints and passing as parameter like this:

fun DrawLines(intSize:IntSize){
// handle lines
}

Is there any better approach or that's all I can do for now?

Thanks for help.

CodePudding user response:

The only other thing you could use is enter image description here

  • Related