'Jetpack Compose Preview in Android Studio picking up the initial value of flowable and shows an empty List

I noticed today that my preview doesn't work if I have a flow as a parameter to a Composable i.e. the below will always render as emptyMap()

@Composable
fun BakesList(
    bakes: Flow<Map<Bake, List<Ingredient>>>,
) {
    val bakesMap by bakes.collectAsState(initial = emptyMap())

    LazyColumn {
      //display columns
      //...
    }
}

If I change my Composable parameter to a Map<Bake, List<Ingredient>> then everything renders correctly. Is there a simple fix for this other than redesigning all my composables?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source