Question : Initialize a kotlin MutableStateFlow without an initial value
Answered by : abdullah-0kvpuik7ilzv
You can't, Mutable stateFlow require an initial value.
One way is to set this value nullable and init it with null.
But it's a trick and there is another way using channel and receive it as flow :
private val _status = Channel<Status>()
val status = statusChannel.receiveAsFlow()
Source : | Last Update : Fri, 03 Jun 22