Closure containing a declaration cannot be used with function builder 'ViewBuilder'

you shouldn't create a variable inside the SwiftUI builder block, you should create it out of the body scope,

  var isHuman = false

  var body: some View {
      Text("Levels \(isHuman)")
  }

Swift UI uses function builders block that can only contain content that is understandable by the builder. Then what you should write inside the builder block is only View Type and [View]  However, if you want to declare a variable you could work around it by introducing it to a new subclass

The purpose of this feature is to enable the creation of embedded DSLs in Swift -- allowing you to define content that gets translated to something else down the line

Note

review your code twice before doing the workaround, probably you have a misunderstanding about how swift-UI works?

Tags:

Swift

Swiftui