SKIE icon indicating copy to clipboard operation
SKIE copied to clipboard

Flows in SwiftUI (preview) - Observing will empty the data when select item fromlist view

Open hanrw opened this issue 6 months ago • 5 comments

kmp code:

val listdata = flow {
        emit(
            listOf(
                Example(
                    id = 0,
                    name = "hello"
                ),
                 Example(
                    id = 1,
                    name = "world"
                )
            )
        )
    }

swiftui code

struct ReproducerView: View {
@State private var selectedId: Int64?
var body: some View {
        Observing(listdata) {
            Text("No Items")
        } content: { listdata in
            List(selection: $selectedId) {
                ForEach(listdata, id: \.id) { data in
                    HStack {
                        Text(data.name)
                        Spacer()
                    }
                }
            }
        }
}
}

issue: the view will show no items after select one of the list item please check the record

https://github.com/user-attachments/assets/5410fd10-ba70-494b-ad48-e6e4067623c0

hanrw avatar Aug 06 '24 14:08 hanrw