When I use this block of code, I want ScrollView and ForEach views to expand when new items are added to ForEach view. But currently it just fills some space that is larger than the view inside ForEach block. How can I make it fill space for only views sizes inside ForEach block of code?
ScrollView {
ForEach(files, id: \.self) { item in
HStack {
Image("file")
Text(item)
.lineLimit(1)
Spacer()
Button {
files.removeAll(where: { $0 == item })
} label: {
Image("close")
}
}
}
}
I tried setting minWidth and maxWidth for scroll view. But that doesn't seem to work