rememberThemeAnimationState

fun rememberThemeAnimationState(themeProvider: ThemeProvider = rememberRuntimeThemeProvider(), animationSpec: AnimationSpec<Float> = tween(300), format: ThemeAnimationFormat = ThemeAnimationFormat.Crossfade, useDynamicContent: Boolean = false): ThemeAnimationState

Creates a state holder for theme toggle animations with customizable animation characteristics and behavior. The state is remembered across recompositions.

Return

A remembered ThemeAnimationState instance that can be used to control theme animations within a Composable.

Parameters

animationSpec

the animation specification for the theme transition. Defaults to a 300ms tween animation.

format

the format/style of the theme animation. Defaults to ThemeAnimationFormat.Crossfade. For more styles, see ThemeAnimationFormat.

useDynamicContent

Whether to capture and animate dynamic content during theme transitions. If set to true, the target content (that is, the theme to which the theme is toggled) will be drawn dynamically and any changes to it, including scrolling, animations etc. will be preserved. Note that the abandoned theme will still be drawn statically, which may lead to inconsistency between the target and abandoned parts of the animation. Defaults to false.