LottieCompositionResult

@Stable()
interface LottieCompositionResult : State<LottieComposition?>

A LottieCompositionResult subclass is returned from rememberLottieComposition. It can be completed with a result or exception only one time.

This class implements State so you either use it like:

val compositionResult = rememberLottieComposition(...)
// Or
val composition by rememberLottieComposition(...)

Use the former if you need to explicitly differentiate between loading and error states or if you need to call await or awaitOrNull in a coroutine such as androidx.compose.runtime.LaunchedEffect.

See also

Functions

await
Link copied to clipboard
abstract suspend fun await(): LottieComposition
Suspend until the composition has finished parsing.

Properties

error
Link copied to clipboard
abstract val error: Throwable?
The exception that was thrown while trying to load and parse the composition.
isComplete
Link copied to clipboard
abstract val isComplete: Boolean
Whether or not the composition is in the process of being loaded or parsed.
isFailure
Link copied to clipboard
abstract val isFailure: Boolean
Whether or not the composition failed to load.
isLoading
Link copied to clipboard
abstract val isLoading: Boolean
Whether or not the composition is still being loaded and parsed.
isSuccess
Link copied to clipboard
abstract val isSuccess: Boolean
Whether or not the composition has succeeded yet.
value
Link copied to clipboard
abstract override val value: LottieComposition?
The composition or null if it hasn't yet loaded or failed to load.

Extensions

awaitOrNull
Link copied to clipboard
suspend fun LottieCompositionResult.awaitOrNull(): LottieComposition?
Like LottieCompositionResult.await but returns null instead of throwing an exception if the animation fails to load.