I try to add and remove sections in the list by using binding value, so when add or remove items form the "listSectins" that will add and remove sections in the list.
@State private var listSectins = ["SectionOne", "SectionTwo"]
var body: some View {
NavigationView {
List(selection: $selection) {
Section {
ForEach(self.firstSectionData) { rowData in
MainMenuRowView(rowData: rowData)
}
.onMove(perform: { indices, newOffset in
self.groupData.rowsGroup[0].move(fromOffsets: indices, toOffset: newOffset)
})
}
.listRowInsets(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 0))
}
}