title: SwiftUI: How to show some toolbar buttons only for iPhone
body: <p>I have a set of toolbar buttons that should be presented only if the device is iPhone (not iPad).</p>
  <p>The following code fails with this error:</p>
  <blockquote>
  <p>Closure containing control flow statement cannot be used with result builder 'ToolbarContentBuilder'</p>
  </blockquote>
  <p>I do understand why it fails, but I am not be able to come up with a solution, which achieves what I need.</p>
  <pre><code>import SwiftUI
  
  struct ContentView: View {
      var body: some View {
          NavigationView {
              List {
                  NavigationLink(
                      destination: Hello(),
                      label: {
                          Text(&quot;Hello&quot;)
                      })
              }
          }
      }
  }
  
  struct Hello: View {
      var body: some View {
          Text(&quot;Hello World&quot;)
              .toolbar() {
                  if UIDevice.current.userInterfaceIdiom == .phone {
                      ToolbarItem(placement: .navigationBarTrailing) {
                          Button(action: {
                              // do something
                          }, label: {
                              Text(&quot;Button1&quot;)
                          })
                      }
                      ToolbarItem(placement: .navigationBarTrailing) {
                          Button(action: {
                              // do something
                          }, label: {
                              Text(&quot;Button2&quot;)
                          })
                      }
                  }
                  ToolbarItem(placement: .navigationBarTrailing) {
                      Button(action: {
                          // do something
                      }, label: {
                          Text(&quot;Button3&quot;)
                      })
                  }
              }
      }
  }
  
  struct ContentView_Previews: PreviewProvider {
      static var previews: some View {
          ContentView()
      }
  }
  </code></pre>
  <p>I'm happy to create a separate function to achieve it. I simply can't figure out how to do it.</p>