https://kotlinlang.org logo
l

Loboda Deni

07/31/2020, 12:33 PM
Hello, can I put the code in a class? something like that:
Copy code
abstract class BaseState(
    private val textState: String
) {

    @Composable
    fun render() {
        Text(
            modifier = Modifier.padding(8.dp),
            text = textState
        )
        renderChild()
    }

    @Composable
    protected abstract fun renderChild()
}
I get an error: e: java.lang.IllegalStateException: Cannot find the Composer class
i want to split states of a fragment into separate classes. it would be nice to implement some kind of state machine, has anyone done that?
t

Timo Drick

07/31/2020, 12:49 PM
I do use classes and define @Composable functions inside. So this is working. I am also unsing interfaces to define commen functions. But i did not used abstract classes. So not sure if this is the problem.