I tried taking input in dialog using `TextField` i...
# compose
v
I tried taking input in dialog using
TextField
inside
Dialog
, when I close the dialog , app crashes saying
Copy code
java.lang.ArrayIndexOutOfBoundsException: length=5120; index=-2
        at androidx.compose.runtime.SlotTableKt.groupSize(SlotTable.kt:2558)
        at androidx.compose.runtime.SlotTableKt.access$groupSize(SlotTable.kt:1)
        at androidx.compose.runtime.SlotReader.groupSize(SlotTable.kt:596)
        at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2215)
        at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2499)
        at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:2625)
        at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:406)
        at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:724)
t
Yesterday i had the same problem during implementing the countdown timer for the dev challenge.
s
t
hmm it says that it is duplicate. And the other issue: https://issuetracker.google.com/issues/180124293 is already fixed.
v
yeah, I think it will be fixed in later beta version
m
I've just stumbled now on it .... what a consolation, I give up for today!
t
I just implemented my own dialog. To be able to continue: (It is not a dialog just an overlay)
Copy code
@Composable
fun SetTimerDialog(currentSeconds: Int, newSecondsSet: (seconds: Int?) -> Unit) {
    var textValue by remember { mutableStateOf(currentSeconds.toString()) }
    Box(Modifier.fillMaxSize().zIndex(10f).background(Color.Black.copy(alpha = 0.75f)), contentAlignment = Alignment.Center) {
        Surface(shape = MaterialTheme.shapes.medium) {
            Column(Modifier.padding(16.dp)) {
                Text("Set count down in seconds.", Modifier.padding(bottom = 4.dp))
                TextField(
                    value = textValue,
                    onValueChange = { textValue = it },
                    keyboardOptions = KeyboardOptions(
                        autoCorrect = false,
                        keyboardType = KeyboardType.Number,
                        imeAction = ImeAction.Done
                    ),
                    keyboardActions = KeyboardActions(onAny = { newSecondsSet(textValue.toInt()) })
                )
            }
        }
    }
}