Reducing space between list rows

Hi,

However I tried to reduce space between list rows in below code I fail, is there any way to reduce this space ?

    @State var flag: Bool = false
    
    var myList: [String] = ["Hello", "World", "SwiftUI"]
    
    var body: some View {
        VStack(alignment: .leading) {
            List (myList, id: \.self) { list in
                    Text(list)
                    .border(Color.black)
                                   .font(.system(size: 12)) // Smaller font size
                                   .frame(maxWidth: .infinity, minHeight: 20, alignment: .leading) // Reduced height
                                   .padding(.vertical, 4) // Minimal padding for vertical spacing
                                   .listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0)) // Remove insets
                                   .listRowSeparator(.hidden) // Hide separator
            }
            .listStyle(.plain)
            
        }
        .overlay(
            RoundedRectangle(cornerRadius: 10)
                .stroke(sysSecondary.opacity(0.4), lineWidth: 1)
        )
        .frame(width: 220, height:260)
        .background(.white)
        .clipShape (RoundedRectangle (cornerRadius: 10))
    }
}
 .frame(maxWidth: .infinity, minHeight: 20, alignment: .leading) // Reduced height

This will not reduce height ; try defining idealHeight as well in addition to minHeight (is it a computed value or a fixed value ?)

Only solution that works for me is to use environment:

     List (myList, id: \.self) { list in
        // your code here
     }
     .environment(\.defaultMinListRowHeight, 12)    // << NEW
     .overlay(
         // your code here

I get this (I've added some bk color to see it better as well as separators

Interesting discussion here: https://stackoverflow.com/questions/60474057/swiftui-reduce-spacing-of-rows-in-a-list-to-null

Reducing space between list rows
 
 
Q