title: SwiftUI: How to make GridItem pushing out to fill the available space
body: <p>I would like to create a <strong>grid with 24 Items in 4 rows</strong>, so each row should have 6 items. All items should be <strong>equally sized</strong> but fill the whole space available, no matter what device the grid is rendered on.</p>
  <p>I already achieved a flexible height for the rows, but the GridItems do not push out in horizontal dimension, although it is a shape, that is said to be pushing out. Well within a LazyHGrid it seems not to push out.</p>
  <p>This is my code:</p>
  <pre><code>struct AllAchievementsView: View {
      
      var gridRows: Array&lt;GridItem&gt;  { [GridItem(), GridItem(), GridItem(), GridItem()] }
  
      var body: some View {
          
          ZStack {
              Color.black
              LazyHGrid(rows: gridRows) {
                  ForEach(0..&lt;24) { index in
                      RoundedRectangle(cornerRadius: 10).foregroundColor(.blue)
                  }
              }.padding()
          }
      }
  }
  </code></pre>
  <p>I tried all variants on GridItem sizing, I tried to add a frame on my Rectangle with .infity, etc. couldn't realize it. Do I really have to make the math programmatically with a GeometryReader?</p>
  <p>I add two images: One shows the result of this code, the other shows, what I want to realize.</p>
  <p><a href="https://i.stack.imgur.com/TMHDG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TMHDG.png" alt="Current result of the code" /></a></p>
  <p><a href="https://i.stack.imgur.com/e7bYn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e7bYn.png" alt="Expected" /></a></p>