Is there a way to get the current size of a screen (width and height) in Compose for a multiplatform approach? So at best for Android, iOS and desktop with one common API that can be used in a shared composable.
s
Stylianos Gakis
05/13/2023, 2:16 PM
You can probably do a top level
Copy code
BoxWithConstraints(Modifier.fillMaxSize(), propagateMinConstraints = true) {
val maxHeight = this.maxHeight
val maxWidth = this.maxWidth
}
And then go from there, implement everything inside that box.
This does introduce one SubcomposeLayout, so it is maybe not optimal, so if someone can come up with a better idea I’m also all ears.
d
dbaelz
05/13/2023, 2:29 PM
BoxWithConstraints is a good starting point. I had the idea to make it available in the custom AppTheme or hand it down with CompositionLocalProvider. Will try it out. Thanks!