toStateFlow

fun <T> Flow<T>.toStateFlow(initialValue: T, started: SharingStarted = SharingStarted.Lazily): StateFlow<T>

Converts a cold Flow into a hot StateFlow in the context of a ViewModel