I have a textfield, and I am trying to goto another view when user input a specific string.
import SwiftUIstruct ContentView: View { @State var whether_go = "No" var body: some View { TextField("Goto?", text: $whether_go) .navigate(to: CircleImage(), when: whether_go == "Yes") }}
This will raise error: Cannot convert value of type 'Bool' to expected argument type 'Binding<Bool>'
Because when
argument need a Binding<Bool>
I tried to use
when: Binding<Bool>(get: whether_happy == "Yes"))
This raise another error: No exact matches in call to initializer.
So what should I do to convert a boolean to Binding<Bool>?