SwiftUI List hidden line separator not working

Hi,

I have the below code as you can see the list doesn't hide its line separator, so is it a bug ? is there any work around ?

    @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)
            }
            .listRowSeparator(.hidden)
            .listStyle(.plain)
            
        }
        .overlay(
            RoundedRectangle(cornerRadius: 10)
                .stroke(sysSecondary.opacity(0.4), lineWidth: 1)
        )
        .frame(width: 220, height:260)
        .background(.white)
        .clipShape (RoundedRectangle (cornerRadius: 10))
    }
}

Answered by NahtanMak in 804247022

You need to use listRowSeparator for Text in the List rather than the List.

List (myList, id: \.self) { list in
    Text(list)
        .listRowSeparator(.hidden)
}
.listStyle(.plain)
Accepted Answer

You need to use listRowSeparator for Text in the List rather than the List.

List (myList, id: \.self) { list in
    Text(list)
        .listRowSeparator(.hidden)
}
.listStyle(.plain)
SwiftUI List hidden line separator not working
 
 
Q