Post

A small but extremely useful foundational API added in #JetpackCompose 1.8: LocalWindowInfo.current.containerSize It's the best way to get the size of the window, which should form the basis for any breakpoint logic for top-level layouts like window size classes. #AndroidDev

4 reposts29 likes

Oh this is perf. Is this is available in all KMP sourcesets or it's backed by android window stuff?

The closest built-in ways before were LocalConfiguration.current.screenWidthDp and LocalConfiguration.current.screenHeightDp, but due to insets and rounding they aren't actually the window size. So it's an improvement without needing more code with WindowMetricsCalculator (and knowing to do that)