Fixed
Status Update
Comments
mg...@google.com <mg...@google.com> #2
Thanks for the excellent bug report!
na...@google.com <na...@google.com> #4
Ime is not necessary part of repro, relayout does it.
@Composable
private fun TextCrash() {
val infiniteTransition = rememberInfiniteTransition(label = "infinite transition")
val padding by infiniteTransition.animateFloat(
initialValue = 0f,
targetValue = 50f,
animationSpec = infiniteRepeatable(tween(1000), RepeatMode.Reverse),
label = "I like to move it move it"
)
Box(
modifier = Modifier
.padding(padding.toInt().dp)
.fillMaxSize(),
contentAlignment = Alignment.Center
) {
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
Text(
text = "Hello Android!".repeat(5),
textAlign = TextAlign.Center,
letterSpacing = 1.sp,
overflow = TextOverflow.Ellipsis,
maxLines = 1
)
}
}
}
Description
saveable
has built-in support for Coroutines'MutableStateFlow
, supporting the following use case:It does this by providing an overloaded function that handles
MutableStateFlow.value
and serializes it when needed.To help people migrate from
saveable
tosaved
, we want to supportMutableStateFlow
in our KotlinX serialization support.While working on getMutableStateFlow CL, I experimented with this idea and created a naive
KSerializer
implementation to handleMutableStateFlow
.Here’s what it could look like:
For serialization, we would use
(value as MutableStateFlow<T>).value
+valueSerializer
to serialize the content. Deserialization works in the opposite direction.Here’s a usage example:
However, calling this without the serializer would cause an exception.
Our variant should work like
saveable
: ifT
(the generic type insaved
) is serializable, it should work without needing the serializer.The goal is to find the best way to support
MutableStateFlow
insaved
.Related to b/378895074 .