I have an animateDpAsState(..), whenever this animation is triggered it changes the Modifier.size(value) of an Image(...) thus causing recomposition.
Is there a way to skip composition phase for this specific scenario? Allowing an image to change its size?
You can do it using
Modifier.drawWithContent,Modifier.drawBeheindor using Canvas which is aSpacerwithModifier.drawBehind. Modifiers with lambda triggerLayout,Layout->DraworDrawphases skippingCompositionas in this answer.The snippet below changes size with animation and if you want size changes to be applied from center you can add translate either
With translation
In these examples only one recomposition is triggered for animation because
reads enabled value but you can handle animations with Animatable which won't trigger any recomposition either.