In my case first setting selected sheet value to nil and then to desired value inside Task did solved the problem:
Task {
self.sheet = nil
self.sheet = .createNew
}
My guess is that assigning selected sheet directly causing the crash because the current sheet is still presented, Setting it to nil first resolves the problem. You could also try setting new value to sheet after delay that view needs to dismiss the current sheet. The code Could be something like that then:
Task {
await try Task.sleep(for: .seconds(0.3))
self.sheet = .createNew
}
or
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
self.sheet = .createNewTag
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: