Dynamic List

Hi,
I am just a beginner in SwiftUI and am trying to create a simple app were users can individually add flashcards. In order to do that I created a list with a couple of default flashcards, however I can not find anything online which explain how to code a section were each user can add theirs from their phones.
Please let me know if you need any extra information, I am at the very beginning so not sure if I explained myself properly.

Thanks
Answered by RevisePal in 669319022
Thank you.
I did add a button to add new flashcards, but it adds them in default. This is the code I've written so far:
struct FlashcardList: Identifiable {
  var id = UUID()
  var flashcard: String
  var subject: String
  var color: Color
  }
   
struct NextView: View {
  @ObservedObject var flashcards = Flashcards()
  
  var body: some View {
     
    ZStack{
      Color.init(red: 0, green: 0.7, blue: 0.3, opacity: 5)
      .ignoresSafeArea(.all)
     
    NavigationView{
      Section{
        NavigationLink(destination:SecondView()){
      Form {
        ForEach(flashcards.items) { item in
          VStack (alignment:.leading){
            Text(item.flashcard).bold().lineLimit(2)
              .foregroundColor(.blue)
              .padding()
            Text(item.subject).foregroundColor(.red)
              .italic()
            .padding()
         }
        }
        .onDelete(perform: deleteItems)
        }
        }
      }
      .navigationBarTitle("Your Flashcards")
           .navigationBarItems(trailing:
    Button(action: {
      let flash = FlashcardList(flashcard: "Preview...", subject: "Chemistry", color: .red)
                    self.flashcards.items.append(flash)
                  }
    ){
      Text("Add")
      Image(systemName: "plus")}
      )
    }
    }     }
  func deleteItems(at offsets: IndexSet){
    flashcards.items.remove(atOffsets: offsets)
  }
}
There should be a button for the user to ask to add a card.
This would append a card to an array of cards
And the List uses this array as data source for display.

See more details (replace students by your flashCards array.
https://stackoverflow.com/questions/56654877/how-to-show-list-of-views-from-a-datasource-like-uitableview-in-swiftui
Accepted Answer
Thank you.
I did add a button to add new flashcards, but it adds them in default. This is the code I've written so far:
struct FlashcardList: Identifiable {
  var id = UUID()
  var flashcard: String
  var subject: String
  var color: Color
  }
   
struct NextView: View {
  @ObservedObject var flashcards = Flashcards()
  
  var body: some View {
     
    ZStack{
      Color.init(red: 0, green: 0.7, blue: 0.3, opacity: 5)
      .ignoresSafeArea(.all)
     
    NavigationView{
      Section{
        NavigationLink(destination:SecondView()){
      Form {
        ForEach(flashcards.items) { item in
          VStack (alignment:.leading){
            Text(item.flashcard).bold().lineLimit(2)
              .foregroundColor(.blue)
              .padding()
            Text(item.subject).foregroundColor(.red)
              .italic()
            .padding()
         }
        }
        .onDelete(perform: deleteItems)
        }
        }
      }
      .navigationBarTitle("Your Flashcards")
           .navigationBarItems(trailing:
    Button(action: {
      let flash = FlashcardList(flashcard: "Preview...", subject: "Chemistry", color: .red)
                    self.flashcards.items.append(flash)
                  }
    ){
      Text("Add")
      Image(systemName: "plus")}
      )
    }
    }     }
  func deleteItems(at offsets: IndexSet){
    flashcards.items.remove(atOffsets: offsets)
  }
}
Dynamic List
 
 
Q