I hope I understand exactly what you want to achieve.
You don't show all code, but you should have a first View (often named ContentView).
It looks like the following:
struct ContentView: View {
// var declarations, Sate var…
@State var showPicker = true // at start only
@State var selectedStagione = "" // You could also set the initial value 2023/2024 here without need for onAppear
var body: some View {
VStack(alignment: .leading) {
// the view content, with the picker for idStagione selection
if showPicker {
// display the Picker
Picker("Please select", selection: $selectedStagione) {
// build Picker items
}
.onChange(of: selectedStagione) { _, _ in // The new format for onChange
showPicker = false
print("Selection done")
}
}
}
.onAppear {
// set idStagione initial value here
selectedStagione = "2023/2024" // adapt as needed
}
}
}
Please tell if you need more explanation ; if so, show your ContentView. If OK, don't forget to close the thread by marking the correct answer.