I am getting the following error "Closure containing control flow statement cannot be used with function builder 'ViewBuilder'" Not able to find similar troubleshoot anywhere.
struct FavoriteView: View {
@EnvironmentObject var userData: UserData
@State var isfavorite = false
var favoriteindex = [1,2,3]
var body: some View {
NavigationView {
List {
ForEach(userData.labvaluesUserdata) {section in
for numbers in favoriteindex {
if section.id == (numbers) {
ItemRow(list: section)
}
}
}
}
}
}
}
With this I am able to get the first index. Any simple way to loop through ?
List {
ForEach(userData.labvaluesUserdata) { section in
if section.id == self.favoriteindex.first {
ItemRow(list: section)
}
}
}