Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does consumedWindowInsets() do? (Android Compose Window Insets)

I'm trying to learn window insets in Compose so I can try to implement edge to edge.

One thing I notice with Scaffold is:

content - content of the screen. The lambda receives a PaddingValues that should be applied to the content root via Modifier.padding and Modifier.consumeWindowInsets to properly offset top and bottom bars. If using Modifier.verticalScroll, apply this modifier to the child of the scroll, and not on the scroll itself.

I'll see references to consumedWindowInsets which want PaddingValues.

What does this exactly do? The documentation on the method doesn't make much sense to me.

like image 528
SmallGrammer Avatar asked Apr 09 '26 22:04

SmallGrammer


1 Answers

I assume you meant Modifier.consumeWindowInsets(...). This function will just consume the provided PaddingValues from the available window insets. So in child components of the modifier or component on which the modifier is applied (going deeper into the composition tree). When you are using Modifier.windowInsetsPadding(...) it will substract the consumed insets from the padding. See also the offical Documentation here: https://developer.android.com/jetpack/compose/layouts/insets#inset-consumption

like image 64
Timo Drick Avatar answered Apr 12 '26 10:04

Timo Drick