I have passed a constant value to Toggle since I want to perform certain acctions on value change of toggle and it needs to be done on Tap Gesture as internally I might need to change the value of toggle as well. But hus code is not working
@State private var toggle = false
var body: some View {
VStack {
Toggle(isOn: .constant(toggle)) {
Text("Hello World")
}
.padding()
.onTapGesture {
print("Tapped")
self.toggle.toggle()
}
}
}
}